Code Snippets

PHP Current Directory

How to get current directory, filename and code line number in PHP

In PHP, there are several built-in functions that can be used to obtain information about the current script’s directory, filename, and code line number. Getting the Current Directory To get the absolute path of the directory containing the current script, you can use the dirname(__FILE__) function. For example: This will set the $current_directory variable to …

How to get current directory, filename and code line number in PHP Read More »

PHP error log - operator not supported

[] operator not supported for strings – PHP

I had a problem with Revolution Slider on a WordPress installation when upgrading to PHP 7.2+. It would generate the error – PHP Fatal error: [] operator not supported for strings in C:[path]\wp-content\plugins\revslider\includes\framework\base-admin.class.php:71 The problem was from the plugin attempting to use the short array push syntax on a string: The solution was to modify …

[] operator not supported for strings – PHP Read More »

Bulk Migrate Users

Bulk Migrate Users to New Blog on WordPress Multisite

Recently I had to move a large number of users from one blog to another on a Multisite install. These users had been mistakenly added to the wrong blog and most of them also had been assigned the wrong role. There were plugin options to do this one by one, but not to bulk migrate users. …

Bulk Migrate Users to New Blog on WordPress Multisite Read More »

Scroll to Top