Debug Print Backtrace PHP

Debug Print Backtrace is a function in PHP. As the name suggests it traces back function calls.

For Example

1. <?php
2. function one(){

 3. two();

4. }

5. function two(){

6. three();

7. }

8. function three(){

9. debug_print_backtrace();

10. }

11. one();

12. ?>

The output would show you the list of functions that were called, starting from the last to the first function along with the line numbers


#0  three() called at 6
#1  two() called at 3
#2  one() called at 11




A PHP Resource

PHP as you know is a popular server side scripting language.  If you want to get started with PHP it might seem  a bit overwhelming at first since you have to setup your own server and then go through different documentation. And sometimes documentation can get quite Intimidating. Fortunately there is a resource that is quite easy to read and it is catered for beginners starting out with PHP and learning the nuances of the language.

It is called PHP the Right Way.  This website covers different topics right from setting up your environment to security, error handling and caching. Hope people Interested in getting started in PHP can take some time perusing this resource 🙂


PHP-array_ fill

Array Fill as the name suggests is used to fill out the Indices of an Array with values. All you have to do is specify the starting Index, the ending Index and the value that you want to fill out the array with.

The syntax goes something like this-

array_fill ( int $start_index , int $end_index ,  $value );
For Example-
This means that you filling the Indices 2,3 and 4 with 25
If you print the array, this would be the output
    [2]  => 25
    [3]  => 25
    [4]  => 25

One could also use this function to Initialize multi dimensional arrays. For example- this is how one would Initialize a 2-Dimensional Array

  $a array_fill(010array_fill(0100));


It is a 10×10 array and all the values are Initialized to 0.


PHP-strpos function

The strpos function in PHP is used to determine whether a string is contained in another string.

For Example

If there is a string A that contains the following words “The cat is sleeping” and you have another string B that contains this “cat”

One could use the strpos function to determine whether string B belongs to any element is string A. In this case the word cat from string B is present in string A


The If Statement

 if( (strpos($A,$B)!==false){

echo “True”;



echo “False”;


Will return True since string B belongs to string A

The common use of this function is to determine the position of the first occurrence of the substring in a string




Error Reporting in PHP

Error Reporting is very Important in order to know exactly which part of the code is not working and to get the cause or the reason for it to not work. We as developers might always think that our code would not run Into any errors after we make the design. But errors are something that happens and it’s something that one does not foresee while coding. It is akin to driving on the road and getting Involved in an accident or if your car breaks down. These events are not planned.

So Suppose we get an error, we need to know what exactly is causing the Issue in order to fix it. Each language has it’s own way for reporting errors. In PHP, in order to enable error reporting, one needs to create a special file in the Project Folder. The file is called php.ini

In this file all you have to do is Include this one line of code-

display_errors = on ;

This turns on error reporting on the project folder.

So, next time if you are working on a project make sure that error reporting is enabled. This is not done by default.


PHP Array Push

The Array Push method in PHP is used for Inserting elements Into an array. The Syntax goes something like this-




$array is the Array

$element is the element that needs to be Inserted Into an array.


For Example-



Now 2 is an element of the array.






get_the_ID() is a php function in WordPress. It retrieves the Post ID for a particular post. In WordPress, each post has a unique ID. There may be situations when you need to apply an action to a specific post. This can be done by using the get_the_ID function.

For Example,

if (get_the_ID() )=212 { ?>


<?php } ?>