Deprecated Constructor in PHP Class

Still converting old PHP code and upgrading to PHP 7.0, I receive a message like this: Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; Validate_fields has a deprecated constructor in Looking at the code I see this: class Validate_fields { var $fields = array(); var $messages = array(); var $check_4html = false; var $language; var $time_stamp; var $month; var $day; var $year; function…

Read More

Use pre Tag to Format Your PHP Code in WordPress Posts

This entry is part 2 of 2 in the series PHP Programming

Taking advice from Writing Code in Your Posts, I am now using only the pre tag to fromat the PHP code in WordPress posts. It will look like this: if (isset($_POST[‘h_sys_submitted’])){ $h_sys = safeEscapeString($_POST[“h_sys_submitted”]); } else{ $h_sys = ”; } if (isset($_POST[‘asc_turned_to_submitted’])) { $asc_turned_to = safeEscapeString($_POST[“asc_turned_to_submitted”]); } else{ $asc_turned_to = ”; }

Change real_escape_string to mysqli_real_escape_string for Function safeEscapeString in PHP 7.0

This entry is part 1 of 2 in the series PHP Programming

I often use function safeEscapeString from¬† in my PHP projects. It helps sustain the integrity of data coming to and from MySQL or similar database. However, if the code ran on PHP 5.4 or 5.6 at the highest, and I wanted it to run PHP 7.0, the latest and greatest version of PHP. When the error reporting is turned on, a fatal error in code will appear. The solution is to use the recommended…

Read More