Get constant value by generated name

Today a colleague of mine ask me if it is possible to call a class constant inside of another class by generating the constant name on the fly. The reason was, that he had multiple constants in one class that had patterned / generic names like that:

And he wanted to address them like […]

Custom install path for composer package

Recently I had to build a custom Composer package that had to be installed to a custom install path inside of the target application. But the install path should have been only different for this single package. All other Composer packages had to be installed unter the vendor folder furthermore. Requirements I had the following requirements […]

PHP version paths under Plesk ODIN

The different PHP versions unter Plesk ODIN are situated in /opt/plesk/php/. So the PHP paths are for example:  /opt/plesk/php/5.2/bin/php /opt/plesk/php/5.3/bin/php /opt/plesk/php/5.4/bin/php /opt/plesk/php/5.5/bin/php /opt/plesk/php/5.6/bin/php /opt/plesk/php/7.0/bin/php Which PHP versions are available depends on the versions installed. You can see your installed versions under https://yourdomain.com:8443/admin/php-handler/list/ in the Plesk backend.

String helper class

Trigger Rest-API via curl

This snippet shows how to call a REST-API via curl. It also tells you how you can do a Basic-HTTP-Authentification to legitimate the call.

IP Detection

This little snippet tries to get the IP-Address of the user:

 

RealNl2Br

Hence nl2br does NOT really replace newlines with <br /> tags (it only inserts a <br /> tag before each \n → newlines themselves are preserved), you can use this function to get it right (realNl2Br):

 

Xdebug

Manual Install The following Instructions based on http://xdebug.org/wizard.php help you to install it manually: Download the latest version (xdebug-x.x.x.tgz) from  http://xdebug.org/download.php Unpack the downloaded file with:

On shell run:

Result should be:

Please consider the number! If you got different results, look at http://xdebug.org/docs/install for help. Next shell commands:

Change or […]

Run PHP script with parameters within another PHP script

Recently I had to call a PHP script within another script with some arguments. Normally you pass these parameters by GET or POST. But how to do it within another script? Here is how to run PHP script with parameters within another PHP script: