|
Posted by Rik on 02/15/07 17:49
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 wor=
k:
----checktype.php5--
echo PHP_VERSION;
--------------------
---check.php--------
echo "Current .php version is ".PHP_VERSION."\n";
$path =3D 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).=
'/';
$php5 =3D 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 =3D version_compare(PHP_VERSION,$php5);
if($result =3D=3D 0){
echo "\nversions are equal"; =
} else {
echo "\nversion used for .php5 is ".(($result=3D=3D-1)?'higher':'lower=
');
}
}
--------------------
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|