Posts

Showing posts with the label PHP

Determine the PHP version, thread safety and architecture on Windows

Determine the PHP version: php -i|find "PHP Version" Determine the thread safety php -i|find "Thread Safety" You’ll have enabled for thread safe or disabled for not thread safe Determine the architecture php -i|find "Architecture" You’ll have x86 for 32 bits and x64 for 64 bits Credit: https://mlocati.github.io/articles/php-windows-imagick.html

Show all PHP errors

ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

Get _id of document in Mongodb using PHP

$documentObject["_id"]->{'$id'}

Capture the output var_dump

ob_start(); var_dump($var); $var_dump = ob_get_clean();

How to Get The Full URL and Parts In PHP

<?php function getFullURL ($strip = false) { // getFullURL() : gets the full URL // PARAM $strip - strip away the query and hash portion // THE PROTOCOL $url = ( isset ($_SERVER[ 'HTTPS' ]) ? "https://" : "http://" ); // HOST $url .= $_SERVER[ 'HTTP_HOST' ]; // SET THE PORT ONLY IF IT IS NOT HTTP/HTTPS if ($_SERVER[ 'SERVER_PORT' ]!= 80 && $_SERVER[ 'SERVER_PORT' ]!= 443 ) { $url .= ":" . $_SERVER[ 'SERVER_PORT' ]; } // THE PATH, FILE NAME, AND QUERY $url .= $_SERVER[ 'REQUEST_URI' ]; // STRIP QUERY AND HASH if ($strip) { $url = strtok($url, '?' ); $url = strtok($url, '#' ); } // THE ENTIRE URL return $url; } ?> Credit: https://code-boxx.com/php-url-parts/