|
Posted by McKirahan on 02/16/07 01:47
"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.tnsw4xtiqnv3q9@misant...
On Thu, 15 Feb 2007 18:12:30 +0100, McKirahan <News@McKirahan.com> wrote:
>> Is there a way to reliably determine if the ".php5" extension
>> must be used on a server? Perhaps via a "phpinfo()" value?
>>
> I tried this (to not write to the file in the function isn't supported):
>
> try {
> file_put_contents($file, $text, FILE_APPEND+LOCK_EX);
> } catch (Exception $e) {
> echo "Caught exception: ", $e->getMessage(), "\n";
> }
>
> but got this error:
>
> Parse error: parse error, unexpected '{' ...
>
> It doesn't like my use of "try - catch".
> Why isn't "try - catch" documented?
> I found only one reference; (under "Exceptions").
try - catch is only usefull for Exceptions, and hence that's where they're
found. Also, Exceptions are introduced in PHP5, so that's no way to fall
back to PHP4.
Usefull for determening current PHP / newer functionality:
<http://www.php.net/phpversion>
<http://pear.php.net/package/PHP_Compat>
Now, I have no idea how to find out the addtype declarations in apaches
configuration with PHP, but this cumbersome workaround will probably work:
----checktype.php5--
echo PHP_VERSION;
--------------------
---check.php--------
echo "Current .php version is ".PHP_VERSION."\n";
$path = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/';
$php5 = file_get_contents($path.'checktype.php5');
if(preg_match('/^<\?/',$php5)){
echo ".php5 is not supported as an extention";
} else {
echo ".php5 uses version ".$php5;
$result = version_compare(PHP_VERSION,$php5);
if($result == 0){
echo "\nversions are equal";
} else {
echo "\nversion used for .php5 is ".(($result==-1)?'higher':'lower');
}
}
--------------------
Thanks for the information.
Navigation:
[Reply to this message]
|