- This topic is empty.
-
AuthorPosts
-
April 2, 2013 at 8:48 am #43839matthiscoParticipant
I’m trying to referece php.ini in my code, I cannot find the file though.
Can anyone please help?
The path to PHP on my server is:
C:Program Files (x86)PHPv5.3
I have omitted the space before the first bracket. DO I need to escape this in my code below?
// try to get path using phpinfo
ob_start();
phpinfo(INFO_GENERAL);
$phpinfo = ob_get_contents();
ob_end_clean();preg_match_all(‘#
]*>(.*)#siU’, $phpinfo, $output);
$output = preg_replace(‘#$output = preg_replace(‘#(w),(w)#’, ‘1, 2’, $output);
$output = preg_replace(‘#border=”0″ cellpadding=”3″ width=”600″#’, ‘border=”0″ cellspacing=”1″ cellpadding=”4″ width=”95%”‘, $output);
$output = preg_replace(‘#
#’, ”, $output);
$output = str_replace(‘‘, ”, $output);
$output = str_replace(‘‘, ”, $output);
preg_match(‘#
Loadeds+Configurations+Files+ .* #’, $output, $match);
$loaded_php = str_replace(‘
Loaded Configuration File ‘, “”, $match[0]);
$loaded_php = str_replace(‘‘, “”, $loaded_php);
// Get Content//
//Please give the path of the loaded php.ini below
//For example: /usr/local/lib/php.ini
$loaded_php = “C:/Program Files(x86)/PHP/v5.3/php.ini”;
if(file_exists($loaded_php))
{
$phpini= file_get_contents($loaded_php);
} else {
$phpini= “nowt”;
}
return $phpini;
}$phpini= getlocalPHPINIcontent();
echo $phpini;?>
April 2, 2013 at 4:25 pm #130466__ParticipantMost of this stuff:
ob_start();
phpinfo(INFO_GENERAL);
$phpinfo = ob_get_contents();
ob_end_clean();preg_match_all(‘#
]*>(.*)#siU’, $phpinfo, $output);
$output = preg_replace(‘##’, ”, $output);
$output = str_replace(”, ”, $output);
$output = str_replace(”, ”, $output);preg_match(‘#Loadeds+Configurations+Files+.*#’, $output, $match);
$loaded_php = str_replace(‘Loaded Configuration File ‘, “”, $match[0]);
$loaded_php = str_replace(”, “”, $loaded_php);…is an attempt to find your `php.ini` file automatically. Why do you throw away all that work immediately after by overwriting the contents of `$loaded_php`? Was it not finding the correct file path?
Likewise, are you sure that `C:/Program Files(x86)/PHP/v5.3/php.ini` is the correct path?
(You can confirm which `php.ini` file PHP is loading by looking at the output of the [`phpinfo()`](http://php.net/phpinfo) function. Simply do this
print phpinfo();
exit;…and then look for the phrase “Loaded Configuration File” (it’s pretty close to the top).
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.