Programming Archives - Page 4 of 9 - Ian Carnaghan

Getting PHP Fatal error: Can’t use function return value in write context

Make sure that you did not include a function within the empty PHP function. eg if(empty(getUsers())){}

Mar 22 · 3 sec read >

How to validate a date format using PHP

To check whether the date entered is in the correct format NOTE: We will use the following date format...

Mar 22 · 15 sec read >

How to compare two dates using PHP

First we need to convert the two dates to UNIX Timestamps using the PHP function strtotime Then we can compare the two...

Mar 22 · 15 sec read >

How to add months to a given date using PHP

By using the PHP functions date and strtotime this can be accomplished. Example  $date = '2010-03-22';   $new_date = date('Y-m-d',strtotime('+4 months',strtotime($date)));   echo $new_date; //Displays...

Mar 22 · 27 sec read >

How to check if an array contains a empty element or value

Use the following code example $array = array('a','b',''); //The array to check for empty values echo (in_array('  ', $array))...

Mar 22 · 10 sec read >

What is the difference between public, private and protected keywords?

Public – Are variables that are visible to all classes Private -Are variables that are visible only to the class they...

Mar 22 · 9 sec read >

How to check for empty values within a array using PHP

If you have an array called $array with the below values Array ( => 1299016800 => => )...

Mar 22 · 25 sec read >

How to transform a month number to the relevant month name using PHP

This can be obtained by combining the date function with the mktime function For example if I want to get Jan from the number 1 which represents...

Mar 22 · 23 sec read >

How to raise the PHP memory limit, upload limit, or script execution time limit within the .htaccess file

Open your .htaccess file and add the line below to it php_value memory_limit 40M This will increase the PHP memory limit, if the altering...

Mar 22 · 6 sec read >