473,544 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.php5 versus .php

I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.

My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.

Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?

I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)

Thanks in advance.
Feb 15 '07 #1
19 2343
"McKirahan" <Ne**@McKirahan .comwrote in message
news:dO******** *************** *******@comcast .com...
I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.

My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.

Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?

I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)

Thanks in advance.

I tried this (to not write to the file in the function isn't supported):

try {
file_put_conten ts($file, $text, FILE_APPEND+LOC K_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 ").
Feb 15 '07 #2
Rik
On Thu, 15 Feb 2007 18:12:30 +0100, McKirahan <Ne**@McKirahan .comwrote:
>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_conten ts($file, $text, FILE_APPEND+LOC K_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($_SERV ER['PHP_SELF']).'/';
$php5 = file_get_conten ts($path.'check type.php5');
if(preg_match('/^<\?/',$php5)){
echo ".php5 is not supported as an extention";
} else {
echo ".php5 uses version ".$php5;
$result = version_compare (PHP_VERSION,$p hp5);
if($result == 0){
echo "\nversions are equal";
} else {
echo "\nversion used for .php5 is ".(($result ==-1)?'higher':'lo wer');
}
}
--------------------

--
Rik Wasmus
Feb 15 '07 #3
McKirahan kirjoitti:
"McKirahan" <Ne**@McKirahan .comwrote in message
news:dO******** *************** *******@comcast .com...
>I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.

My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.

Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?

I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)

Thanks in advance.


I tried this (to not write to the file in the function isn't supported):

try {
file_put_conten ts($file, $text, FILE_APPEND+LOC K_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 ").

Don't know if these help you any but two observations:

1) you can get the version of php with phpversion();
http://fi.php.net/manual/en/function.phpversion.php

2) You can test wether a function exists with

if(function_exi sts('file_put_c ontents')){
file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
} else {
echo "craptastic !";
}
--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
sp**@outolempi. net | Gedoon-S @ IRCnet | rot13(xv***@bhg byrzcv.arg)
Feb 15 '07 #4
On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
McKirahan kirjoitti:
"McKirahan" <N...@McKirahan .comwrote in message
news:dO******** *************** *******@comcast .com...
I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.
My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.
Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?
I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)
Thanks in advance.
I tried this (to not write to the file in the function isn't supported):
try {
file_put_conten ts($file, $text, FILE_APPEND+LOC K_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 ").

Don't know if these help you any but two observations:

1) you can get the version of php with phpversion();http://fi.php.net/manual/en/function.phpversion.php

2) You can test wether a function exists with

if(function_exi sts('file_put_c ontents')){
file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);} else {

echo "craptastic !";

}

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
also your code had a typo in it:

try
{
file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
}
catch (Exception $e)
{
echo "Caught exception: ". $e->getMessage() , "\n";
} |
_______________ ___________|
(should have been a dot after caught exception)

as for .php5, just use an .htaccess file to rewrite all extensions of
one sort to the other, whatever suits. 1and1 are like this, but the
htaccess rewrite rules work fine.

Feb 15 '07 #5
On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:
McKirahan kirjoitti:
"McKirahan" <N...@McKirahan .comwrote in message
news:dO******** *************** *******@comcast .com...
I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.
My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.
Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?
I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)
Thanks in advance.
I tried this (to not write to the file in the function isn't supported):
try {
file_put_conten ts($file, $text, FILE_APPEND+LOC K_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 ").

Don't know if these help you any but two observations:

1) you can get the version of php with phpversion();http://fi.php.net/manual/en/function.phpversion.php

2) You can test wether a function exists with

if(function_exi sts('file_put_c ontents')){
file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);} else {

echo "craptastic !";

}

--
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
oh and of course, dont forget the other typo ,->. further on the same
line!!

Feb 15 '07 #6
"Rik" <lu************ @hotmail.comwro te in message
news:op.tnsw4xt iqnv3q9@misant. ..
On Thu, 15 Feb 2007 18:12:30 +0100, McKirahan <Ne**@McKirahan .comwrote:
>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_conten ts($file, $text, FILE_APPEND+LOC K_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($_SERV ER['PHP_SELF']).'/';
$php5 = file_get_conten ts($path.'check type.php5');
if(preg_match('/^<\?/',$php5)){
echo ".php5 is not supported as an extention";
} else {
echo ".php5 uses version ".$php5;
$result = version_compare (PHP_VERSION,$p hp5);
if($result == 0){
echo "\nversions are equal";
} else {
echo "\nversion used for .php5 is ".(($result ==-1)?'higher':'lo wer');
}
}
--------------------

Thanks for the information.
Feb 16 '07 #7
"Kimmo Laine" <sp**@outolempi .netwrote in message
news:er******** **@nyytiset.pp. htv.fi...
McKirahan kirjoitti:
"McKirahan" <Ne**@McKirahan .comwrote in message
news:dO******** *************** *******@comcast .com...
I am working in two environments neither configuration of
which I can change; one's my Web host the other a client.

My Web host requires the use of the ".php5" extension
to use PHP v5.1.4; where ".php" is used for PHP v4.3.11.
My client supports PHP v5.2.0 with the ".php" extension.

Is there a way to reliably determine if the ".php5" extension
must be used on a server? Perhaps via a "phpinfo()" value?

I have a page that uses the v5 function "file_put_conte nts()".
(I like it's LOCK_EX feature.)

Thanks in advance.

I tried this (to not write to the file in the function isn't supported):

try {
file_put_conten ts($file, $text, FILE_APPEND+LOC K_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 ").

Don't know if these help you any but two observations:

1) you can get the version of php with phpversion();
http://fi.php.net/manual/en/function.phpversion.php

2) You can test wether a function exists with

if(function_exi sts('file_put_c ontents')){
file_put_conten ts($file, $text, FILE_APPEND+LOC K_EX);
} else {
echo "craptastic !";
}
Thanks! I'm going to use "function_exist s()".
Feb 16 '07 #8
"shimmyshac k" <ma********@gma il.comwrote in message
news:11******** **************@ a34g2000cwb.goo glegroups.com.. .
On Feb 15, 6:05 pm, Kimmo Laine <s...@outolempi .netwrote:

[snip]
"En ole paha ihminen, mutta omenat ovat elinkeinoni." -Perttu Sirviö
s...@outolempi. net | Gedoon-S @ IRCnet | rot13(x...@bhgb yrzcv.arg)
oh and of course, dont forget the other typo ,->. further on the same
line!!
Please notify the PHP Documentation Group; here's their example:

Chapter 20. Exceptions

Example 20-1. Throwing an Exception

<?php
try {
$error = 'Always throw this error';
throw new Exception($erro r);

// Code following an exception is not executed.
echo 'Never executed';

} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage() , "\n";
}

// Continue execution
echo 'Hello World';
?>

Feb 16 '07 #9
Rik
On Fri, 16 Feb 2007 02:48:06 +0100, McKirahan <Ne**@McKirahan .comwrote:
Thanks! I'm going to use "function_exist s()".
Don't forget PEAR PHP_Compat, saves a lot of headaches in trying to write
your own workarounds...
--
Rik Wasmus
Feb 16 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3674
by: Christoph Nothdurfter | last post by:
Hallo! I was wondering if my PHP4-Scripts will run under PHP5 (Haeven't tried the beta yet). Does anybody know? Thank you, -Christoph
8
2963
by: Rob Ristroph | last post by:
I have tried out PHP 5 for the first time (with assistance from this group -- thanks!). The people I was working with have a site that uses lots of php objects. They are having problems with speed. They had a vague idea that PHP5 has improved handling of objects over PHP4, so it would probably be faster also. In fact it seems slower. ...
11
10565
by: neur0maniak | last post by:
Hi, I've been eager to try out PHP5, so I've dumped it on my little dev machine. It's running WinXP with IIS5. I've put the php-cgi.exe in the "mappings" page as I'm used to doing with PHP4. I've got my php.ini all set in C:\Windows. I created an index.php containing: <?php phpinfo(); ?> When I try to view the page, I get "HTTP 400 - Bad...
4
5829
by: badbetty | last post by:
Dear Googlers I have installed PHP5 to run on WinXP against Apache 2. It works! ie. I have tested a few simple scripts and a basic xml document parse. I now want to try the XSL extension so I can transform xml docs. Having copied the php_xsl.dll to a directory where it can be found and done the uncommenting in php.ini, it still will...
2
1383
by: sheldonlg | last post by:
I have a page with multiple submit buttons. Call them "ok" and "cancel". I have the coding in PHP as: if (isset($ok)) { something } and if (isset($cancel)) { something else } This works fine in PHP 4.X. In PHP5 it doesn't work at all (no action at all). What is the replacement coding and how can I code so that it works in all...
5
2144
by: Aziz | last post by:
Hi, I've recently contacted technical service of a web hosting company and asked them wheter or not they're gonna upgrade to PHP5 and MySQL5. Here's a quote from their response which confused me a little: "As php5 and mysql5 are still beta versions we don't install beta versions on production servers due to secure reasons, we install only...
4
2746
by: Chuck Anderson | last post by:
I am trying to install Php5 on my WindowsXP machine (at home, not on the 'net). I downloaded the Php Windows binary at php.net, unzipped it to c:/Php5, changed my Apache config file to use Php5 with: LoadModule php5_module "c:/Php5/php5apache2.dll" .... and restarted apache (Apache/2.0.55 (Win32) mod_ssl/2.0.55 OpenSSL/0.9.8a) Php5...
3
3285
by: xhe | last post by:
I have just upgraded my php version form php4 to php5. and I met this problem, and don't know if you know the solution. My site was written in PHP4, and most parts can be running smoothly in PHP5, only that in old version, I can use $row to access the data in database directly, no need to put double quote around fieldname. BUT in PHP5, this...
8
2302
by: FFMG | last post by:
Hi, I am slowly moving my code to php5. But I would like to make it backward compatible in case something bad happens, (and to make sure I understand what the changes are). The way the constructors work seem to have changed quite a bit and I am not getting the same behavior across the versions. // Some simple code/
0
7429
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7368
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7614
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7384
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5916
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3414
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
990
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.