473,327 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

PHP4 vs 5 programming

Hi

Since PHP5 classes use the __constructor() method, and PHP4 still
requires the classname as constructor, is there an easy way to
incorporate both in my class definitions so the class is usable in both
versions?

I know php5 will look for an old style constructor if there is no
__constructor definition, but I am convinced this will be deprecated in
future versions...

KR
Schraalhans
Feb 13 '06 #1
3 2401
Schraalhans Keukenmeester wrote:
Hi

Since PHP5 classes use the __constructor() method, and PHP4 still
requires the classname as constructor, is there an easy way to
incorporate both in my class definitions so the class is usable in both
versions?

I know php5 will look for an old style constructor if there is no
__constructor definition, but I am convinced this will be deprecated in
future versions...


You could try doing something like:

class MyClass {
function __construct () {
$this->MyClass ();
}
}

I am personally starting to move over to PHP5 breaking PHP4 compat. ;)

--
Justin Koivisto, ZCE - ju****@koivi.com
http://koivi.com
Feb 13 '06 #2
On Mon, 13 Feb 2006 18:49:52 +0100, Schraalhans Keukenmeester
<no**@nowhere.nil> wrote:
Hi

Since PHP5 classes use the __constructor() method, and PHP4 still
requires the classname as constructor, is there an easy way to
incorporate both in my class definitions so the class is usable in both
versions?


Nothing is stopping you from declaring both... one will be called in
PHP4, the other in PHP5. You can then make a call from one to the
other, if you like.

Feb 13 '06 #3
Wayne wrote:
Nothing is stopping you from declaring both... one will be called in
PHP4, the other in PHP5. You can then make a call from one to the
other, if you like.


Yep. Only thing is, you get a "strict" warning for redeclaring the
constructor in php5.

--
E. Dronkert
Feb 13 '06 #4

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

Similar topics

5
by: Tim Tyler | last post by:
I'm sure this is a FAQ - but I could not find a coherent statement of the answer: Some of my clients want PHP4. Other ones want PHP5. Can I run both PHP4 and PHP5 under the same instance of...
2
by: Mike Morris | last post by:
Hi, I've setup a postgres server (7.4) and confirmed that SSL is enabled - I can successfully connect via tcp socket over SSL using the psql client. From PHP4, how can I get the pg_connect...
2
by: Stefan Huber | last post by:
Hi I've got a really strange problem, and can't find out why it's not working as intended. in order to use php4 and 5 together on a webserver and the requirement for running as different...
7
by: Mathieu Maes | last post by:
Hi there I'm quite experienced in programming in PHP4, but I would like to make a step to PHP5. I created following class which works perfectly in PHP4 : Class Nessi { // ident part
12
by: Drazen Gemic | last post by:
How long will PHP4 be supported ? When is PHP4 end of life scheduled ? DG
2
by: mun | last post by:
My server is in the US and I want to set a different timezone (GMT +7), so that I can have an appropriate time for my country. How to do this in php4?
3
by: doctorhardik | last post by:
hai all i am try configure php4.3.9 on my FC-3 machine. and my mysql database version 5.0.1, in phpinfo file it show mysql but when i run php -v command it show error like
8
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...
14
by: Jeff | last post by:
I'm working on a server that is running PHP4. I'd like to upgrade this so I can use the PHP5 code I have already. What kind, if any, problems will I have with the existing PHP code base? I...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.