Tag Archives: phpinfo

Something for your empty home

Here are few lines of code that I have repeatedly found useful, especially when moving home between different web hosts.

Print the complete address of the page from where it is hosted:

<?php
$pageURL = $_SERVER[‘HTTPS’] == ‘on’ ? ‘https://’ : ‘http://’;
$pageURL .= $_SERVER[‘SERVER_PORT’] != ’80’ ? $_SERVER[“SERVER_NAME”].”:”.$_SERVER[“SERVER_PORT”].$_SERVER[“REQUEST_URI”] : $_SERVER[‘SERVER_NAME’] . $_SERVER[‘REQUEST_URI’];
echo $pageURL;
?>

Everyone knows about phpInfo – a dump of all the PHP settings:

<?php phpinfo(); ?>

When using a shared host that allows overriding your PHP ini file, it is worth while knowing the path from where the file is loaded:

<?php var_dump( get_cfg_var(‘cfg_file_path’) ); ?>