What does notice: Undefined Variable in PHP Scripting mean?

The notice: undefined variable means, as the name it says, the variable is not defined. Notice undefined variable Look at the below code <?php if(!empty($employees_data)){ $employee_phone_number=Get_Employee_Phone_Number(); } echo $employee_phone_number ?> Can you guess, what would be the result? It will show, Notice: undefined variable error. Reason: the variable $employee_phone_number variable is defined inisde the if […]

What is the efficient way to fix notice undefined offset array index in PHP?

Array datatype in php contains different values and these values are fetched using index number. Often dealing with array, we encounter undefined offset. What causes undefined offset notice? Lets understand with the help of an example. Example <?php $fruits=array(“apple”,”orange”,”grape”, “guava”,”mango”); ?>   In the above example, $fruits array contains fruit names. If I want to get […]

Create Table in webpage using PHP Code

The power of PHP is it can easily embed HTML Codes. To create any html elements lets say a table, we can use PHP to create a table. Create Table Using PHP We have to echo out all the table tags and its respective data. Note: If you are looking for a solution to create […]

How to calculate size of an Image using PHP?

One prime approach to implement fast loading webpage is to provide image size that is width and height data to the image tag. It will render fast. Even in Accelerated Mobile Page (AMP) implementation it is mandatory to provide image width and height inside the image tag(amp-img). That’s why we need to calculate the size […]

What is the best way to calculate the size of an Array in PHP?

In some cases we may need to know the number of elements present inside an array. PHP has provided two functions that calculates the total elements present inside an array and returns the value. Count() Function PHP has count function which counts the array size. Example; <? $fruits=array(“orange”,”grape”,”apple”); echo count($fruits); ?> output: 3 sizeOf() function […]

How can we use JSON in PHP Scripting?

JSON in PHP – JSON is not object, not an array or any kind of datastructure. People often misunderstood it. JSON is serialized data. JSON is useful to send data in key value format. JSON – Javascript Object Notation How to use JSON in PHP? Lets understand the usage of json in php files. Example […]

How can we use SQL in PHP Server Side Scripting?

PHP has predefined functions that helps us to use SQL syntax inside a php file. SQL in PHP We can execuate following sql related task. Establish connection with database Syntax mysqli_connect(hostname, username, password, databasename) Example <?php $conn=mysqli_connect(“localhost”,”root”,”password”,”root_database”); if($conn){ echo “connected to database”; }else{ echo “failed to connect to the database check connection parameters”; } ?> […]