I use WampServer Version 2.2 on Windows 7, Apache version 2.2.22 and PHP version 5.3.13.
I try to use $this->url = $_SERVER['PATH_INFO']; in the Request file,
I received this error:
Notice: Undefined index: PATH_INFO in C:\wamp\www\site\core\Request.php on line 8
I tried to configure the httpd.conf file to add AcceptPathInfo On
For PHP in php.ini so I added cgi.fix_pathinfo = 1 but this did not fix the problem.
How can I fix this?
PATH_INFO is undefined if you aren't using URL rewriting (or rather: referencing your PHP file 'as a directory'), see here: What exactly is PATH_INFO in PHP?
So if you're doing this: GET /foo/bar.php?query=foo then PATH_INFO will be undefined.
If you do this: GET /foo/bar.php/baz?query=foo then PATH_INFO will be defined as /baz.
for example
ROOT = 'C:\wamp\www\mySite'
it may be helpful to you to get the same result ($_SERVER['PATH_INFO']) if you use this code:
<?php
class App{
public static function get__PATH_INFO($path){
$path_elements = explode("/", $path);
$tempPI = "";
if (isset($path_elements[2])){
for ($i = 2 ;$i < count($path_elements); $i++ )
$tempPI .= "/".$path_elements[$i];
}
return $tempPI;
}
}
?>
then you call the function get__PATH_INFO() in another file:
$path_info = App::get__PATH_INFO($_SERVER['REQUEST_URI']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With