Quick question. Hoping someone can point me in the right direction. At the top of all my pages I have: $url_web = "http://".$_SERVER['HTTP_HOST']; Code (markup): So I include that in all my paths to add an absolute URL to my links src="<?php echo $url_web.'/images/banners/choose_webdesign9.jpg';?>" Code (markup): This works fine on my home page but when I reference an include file on that home page, my links don't seem to recognize the $url_web. Am I missing something somewhere? How do I get the absolute path to apply to all files?
It all depends on the content. If you have declared the variable within a function, it will only have a local scope. Likewise, if you've declared the variable in a global context but attempt to reference to within a local scope (i.e. function), you will be unable to do so unless you take advantage of the global keyword. One thing you could try using is $GLOBALS['url_web'];
I think he tries include php script from absolute page ( include($url_web."something.php"); ) that's wrong, you are not allowed to call absolute url in including
found a fix. To set an absolute path for includes use: <?php include($_SERVER['DOCUMENT_ROOT']."/includes/file.php"); ?> Code (markup): Then update your php.ini in your root directory with include_path include_path=".:path to your server/includes" Code (markup):