Server Side Programming Articles - Page 2244 of 2650

C++ Program to Create a Random Linear Extension for a DAG

Smita Kapse
Updated on 30-Jul-2019 22:30:26

166 Views

Here we will see how to create Random Linear Extension of a Directed Acyclic Graph (DAG). The Linear extension is basically the topological sorting of DAG. Let us consider the graph is like below −The topological sorting for a directed acyclic graph is the linear ordering of vertices. For every edge u-v of a directed graph, the vertex u will come before vertex v in the ordering.As we know that the source vertex will come after the destination vertex, so we need to use a stack to store previous elements. After completing all nodes, we can simply display them from ... Read More

What are getters and setters methods in PHP?

Alok Prasad
Updated on 31-Dec-2019 08:57:06

15K+ Views

In this article, we learn the best way to create getter and setter strategies in PHP. Getter and setter strategies are utilized when we need to restrict the direct access to the variables by end-users. Getters and setters are methods used to define or retrieve the values of variables, normally private ones.Just as the name suggests, a getter method is a technique that gets or recovers the value of an object. Also, a setter method is a technique that sets the value of an object.ExampleLet's understand the use of getter and setter methods through an example.Output:PHP Error Cannot access private ... Read More

Explain Polymorphism in PHP.

Alok Prasad
Updated on 30-Jul-2019 22:30:26

12K+ Views

To begin with, Polymorphism is gotten from the Greek words Poly (which means many) and morphism (which meaning forms).Polymorphism portrays an example in object-oriented programming where methods in various classes that do similar things should have a similar name. Polymorphism is essentially an OOP pattern that enables numerous classes with different functionalities to execute or share a commonInterface. The usefulness of polymorphism is code written in different classes doesn't have any effect which class it belongs because they are used in the same way. In order to ensure that the classes do implement the polymorphism guideline, we can pick between ... Read More

How to display errors in PHP file?

Alok Prasad
Updated on 07-Oct-2023 02:49:53

39K+ Views

A PHP application produces many levels of errors during the runtime of the script . So in this article, we will learn how to display all the errors and warning messages. The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); The ini_set function will try to override the configuration found in your php.ini file. If in the php.ini file display_error is turned off it will turn that on in the code. It also set display_startup_errors to true to show the error message. error_reporting() ... Read More

What is "namespace" keyword in PHP?

Alok Prasad
Updated on 31-Dec-2019 08:53:49

369 Views

In this article, we are going to learn about namespace in PHP. In PHP when we are creating large applications or when integrating third-party applications/library then there may be chances of collision between class names, function names. So to avoid these problems PHP "Namespaces" provide a way in which to group related classes, interfaces, functions and constants.Let's see the syntax of declaring namespace below.SyntaxIn the PHP world, namespaces are intended to take care of two issues that creators of libraries and applications experience when making re-usable code components, Those are:1.Name impact between code you create, and internal PHP classes/functions/constants or ... Read More

Explain include(),require(),include_once() and require_once() functions in PHP.

Alok Prasad
Updated on 30-Jul-2019 22:30:26

4K+ Views

In this article, we will learn about useful and important functions in PHP for file inclusion. All these functions require, require_once, include and include_once are utilized to include the files in the php page but there is a slight distinction among them in terms of functionality.Let's discuss these functions below with their functionality.include() :This function is used to include a file in a PHP page. If include() function is not able to find a specified file on location at that time it will throw a warning message however, it will not stop script execution.require():This function is utilized to add a ... Read More

Convert object to an array in PHP.

Alok Prasad
Updated on 30-Jul-2019 22:30:26

9K+ Views

In a PHP application, we are working with data in various formats such as string, array, objects or more...In a real-time application, we may need to read a php object result in the form of an associative array to get the desired output.So we will discuss here how to transform a php object to an associative array in PHP.Let's explain what is an object and associative array in PHP? An object is an instance of a class meaning that from one class you can create many objects. It is simply a specimen of a class and has memory allocated. While ... Read More

Comparison of floating point values in PHP.

Alok Prasad
Updated on 31-Dec-2019 08:15:59

923 Views

In PHP, testing floating point values for equality is problematic, because PHP is failing when checking if one floating point number is equal to another. Despite the fact floating point numbers seems to have the same value do not need to actually be identical. So in this article will demonstrate the problem we are facing in comparison of Floating-Point Numbers and different procedures to avoid this problem.ExampleLet's test this with a simple example:output:a and b are not same.Explanation:In this code, the else condition is executed instead of the if condition, even though $a and $b are the same. It is ... Read More

Concatenation of two strings in PHP

Alok Prasad
Updated on 30-Jul-2019 22:30:26

3K+ Views

PHP offers different kinds of operators having distinctive functionalities. Operators enable us to perform arithmetic activities, string concatenation, compare values and to perform boolean operations, more...In this article, we will learn string operators given by PHP. Let's first learn the types of string operators in php. There are two string operators provided by PHP.  1.Concatenation Operator ("."):      This operator combines two string values and returns it as a new string. 2.Concatenating Assignment operator (".="):      This operation attaches the argument on the right side to the argument on the left side. Let's demonstrate the utility of the above operators by following examples.Example:Output ... Read More

Comparison of dates in PHP

Alok Prasad
Updated on 30-Jul-2019 22:30:26

7K+ Views

Matching two dates in PHP is quite smooth when both the dates are in a similar format but php failed to analyze when the two dates are in an unrelated format. In this article, we will discuss different cases of date comparison in PHP. We will figure out how to utilize DateTime class, strtotime() in comparing dates.Case 1:we can analyze the dates by simple comparison operator if the given dates are in a similar format.Output:2019-03-26 is latest than 2018-11-24Explanation:Here we have declared two dates $date1 and $date2 in the same format. So we have used a comparison operator(>) to compare ... Read More

Advertisements