PHP Variables – Check if a variable is an array

In this post we will be creating PHP script that will check if an existing variable is an array, to do this we will be using the ‘is_array()’ function. See our array of items for our first example below. In the snippet of PHP code below we are applying the ‘is_array()’ function to check whetherContinue reading “PHP Variables – Check if a variable is an array”

PHP Variables – Check if a variable is a string

In this post we will be creating PHP script that will check if an existing variable is a string, to do this we will be using the ‘is_string()’ function. For this example our variables will be stored in an array and we will carry out a check on each item within. See our array ofContinue reading “PHP Variables – Check if a variable is a string”

PHP Variables – Check if a variable is null

In this post we will be creating PHP script that will check if an existing variable is null, to do this we will be using the ‘is_null()’ PHP function. For this example our variables will be stored in an array and we will carry out a check on each item within. See our array ofContinue reading “PHP Variables – Check if a variable is null”

PHP – Check if a string ends with a substring

In this post we will be creating a PHP script that will check if an existing string ends with a certain character or word. To do this we will be using the ‘str_ends_with()’ function which checks if a string ends with a given substring. Our string for the example will be ‘hello world’, see theContinue reading “PHP – Check if a string ends with a substring”

PHP Variables – Check if a variable is a float

In this post we will be creating PHP script that will check if an existing variable is of a float type, to do this we will be using the ‘is_float()’ function. For this example our variables will be stored in an array and we will carry out a check on each item within. See ourContinue reading “PHP Variables – Check if a variable is a float”

PHP Server – Get the client IP address

In this post we will be creating a PHP script that will return the client IP address, to do this we will be using the ‘$_SERVER’ variable which contains server and execution environment information The ‘$_SERVER’ is an array and in this post we will be retrieving the ‘REMOTE_ADDR()’ item, see the snippet of codeContinue reading “PHP Server – Get the client IP address”

PHP Date Time- Get difference in days between two dates

In this post we will be creating a PHP script that will calculate the difference in days between two given dates. To do this we will be using the date time ‘diff()’ function which returns the difference between two date time objects. See below where we declare our two date time objects. In the snippetContinue reading “PHP Date Time- Get difference in days between two dates”

PHP Server – Get the current URL

In this post we will be creating a PHP script that will return the current URL, to do this we will be using the ‘$_SERVER’ variable which contains server and execution environment information The ‘$_SERVER’ is an array and in this post we will be retrieving the ‘REQUEST_URI’ item, see the snippet of code belowContinue reading “PHP Server – Get the current URL”