Server Side Programming Articles - Page 2239 of 2650

What is PHP Output Buffering?

Alok Prasad
Updated on 29-Jun-2020 11:23:08

3K+ Views

Output Buffering is a method to tell the PHP engine to hold the output data before sending it to the browser. As we know PHP sent the output data to the browser in pieces, but if we utilize the output buffering mechanism, the output data is stored in a variable and sent to the browser as one piece at the end of the script.ExampleLet's demonstrate with a simple example. Live DemoOutputstring(5) "Hello" string(20) "HelloTutorials Point"ExplanationIn the above example ob_get_contents() grabs all of the data gathered since we called ob_start, i.e. everything in the buffer. After that send the output data at ... Read More

Does Python support polymorphism?

AmitDiwan
Updated on 12-Aug-2022 12:21:42

1K+ Views

Yes, Python supports polymorphism. The word polymorphism means having many forms. Polymorphism is an important feature of class definition in Python that is utilised when you have commonly named methods across classes or sub classes. Polymorphism can be carried out through inheritance, with sub classes making use of base class methods or overriding them. There are two types of polymorphism Overloading Overriding Overloading Overloading occurs when two or more methods in one class have the same method name but different parameters. Overriding Overriding means having two methods with the same method name and parameters (i.e., method signature). One ... Read More

Compare define() vs const in PHP

Alok Prasad
Updated on 31-Dec-2019 10:10:49

5K+ Views

As we know both define() and const are used to declare a constant in PHP script.SyntaxLet's discuss the difference between these two.The basic difference between these two is that const defines constants at compile time, whereas define() defines them at run time.We can't use the const keyword to declare constant in conditional blocks, while with define() we can achieve that.const accepts a static scalar(number, string or other constants like true, false, null, __FILE__), whereas define() takes any expression.consts are always case sensitive, whereas define() allows you to define case insensitive constants by passing true as the third argument.const can also ... Read More

How to convert XML file into array in PHP?

Alok Prasad
Updated on 29-Jun-2020 11:04:27

2K+ Views

To convert the XML document into PHP array, we have to utilize some PHP functions. The procedure is explained underneath with an example.Step 1We have to create an XML file that needs to convert into the array.abc.xml           AL       A                    SA          S     Step 2The above XML file will import into PHP using file_get_contents() function which read the entire file as a string and stores into a variable.Step 3After the above step, we ... Read More

How to Check if PHP session has already started?

Alok Prasad
Updated on 29-Jun-2020 09:48:01

4K+ Views

In PHP, we utilize session_start() an inbuilt function to start the session .But the problem we face in a PHP script is if we execute it more than once it throws an error. So here we will learn how to check the session started or not without calling session_start() function twice.There are two ways to follow to resolve this problem.For below PHP 5.4.0 version.ExampleExplanationIf the session not started this code above will always start the session in the PHP script.In the second method, we can utilize the function session_status(), which returns the status of the present session. This function can ... Read More

C++ Program to Create the Prufer Code for a Tree

Anvi Jain
Updated on 30-Jul-2019 22:30:26

822 Views

Prufer code uniquely identifies a tree which is given by user as a graph representation with labels from 1 to p. This tree consist p(value is given by user) labels of node. It has sequence of p – 2 values.AlgorithmBegin    Declare i, j, ver, edg, minimum, p to the integer datatype.    Print “Enter the number of vertexes: ”.    Enter the value of ver.    Initialize edg = ver-1.    Declare EDG[edg][2], DG[ver+1] to the integer datatype.       Initialize DG[ver+1] = {0}.    Print “This tree has (value of edg) edges for (value of ver) vertexes”. ... Read More

Print prime numbers in a given range using C++ STL

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

623 Views

It is the program to print prime numbers in a given range.AlgorithmsBegin    Declare a user define datatype stl.    Declare a vector number to the stl datatype.    Declare variable a to the stl datatype.    Declare vector Prime_Number to the Boolean datatype.       Prime_Number[0] = false.       Prime_Number[1] = false.    Declare b to the integer datatype.       Initialize b = sqrt(a).    for (stl pr=2; pr

C++ Program to Find Closest Pair of Points in an Array

Anvi Jain
Updated on 30-Jul-2019 22:30:26

845 Views

This is the program to find closest pair of points in an array.AlgorithmsFor Distance between Closest pointBegin    Declare function Closest_dist_Spoint(poi stp[], int s, double dist, poi &pnt1, poi &pnt2) to the double datatype.    Declare Minimum to the double datatype.       Initialize Minimum = dist.    for (int i = 0; i < s; ++i)       for (int j = i+1; j < s && (stp[j].poi2 - stp[i].poi2) < Minimum; ++j)          if (Distance(stp[i], stp[j]) < Minimum) then          Minimum = Distance(stp[i], stp[j]).             ... Read More

C++ Program to Implement Sparse Array

Tapas Kumar Ghosh
Updated on 01-Jul-2025 15:30:33

3K+ Views

What is Sparse Array?Sparse array is used to determines the dimension of an array in which most of the elements are zero. It can be used for matrix calculation. Characteristics of Sparse Array Following are list of points that defines the characteristics of a sparse array: Most of the elements are zero or null values which means it is unused. Only non-zero elements and their indexes are stored. It is used to save the memory while comparing to normal array calculation. Example The Sparse array of ... Read More

C++ Program to Find the maximum subarray sum using Binary Search approach

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

346 Views

Binary search is a fast search algorithm with run-time complexity of Ο(log n). This search algorithm works on the principle of divide and conquer. For this algorithm to work properly, the data collection should be in the sorted form.Binary search looks for a particular item by comparing the middle most item of the collection. If a match occurs, then the index of item is returned. If the middle item is greater than the item, then the item is searched in the sub-array to the left of the middle item. Otherwise, the item is searched for in the sub-array to the ... Read More

Advertisements