FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » Weirdness in PHP 4.3.4
Show: Today's Messages :: Unread Messages :: Show Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Weirdness in PHP 4.3.4 [message #14597] Tue, 18 November 2003 09:52
Olliver   Germany
Messages: 443
Registered: March 2002
Karma: 0
Senior Member
add to buddy list
ignore all messages by this user
You may know the classic demonstration about the different behaviour of constructors in PHP 3 and PHP 4 in the manual. Here it is as a small reminder:
Quote:

class A {
    function A() {
        echo "I am the constructor of A.<br>\n";
    }

    function B() {
        echo "I am a regular function named B in class A.<br>\n";
        echo "I am not a constructor in A.<br>\n";
    }
}

class B extends A {
    function C() {
        echo "I am a regular function.<br>\n";
    }
}

$b = new B;



PHP 4 regards a function as constructor if it has been defined as such in the class it's residing. Class B hasn't got a constructor, however it's extended by A which means it inherits the constructor (though it's called "A" and not "B") and we see
I am the constructor of A
as output.

So far so good. However it seems that PHP 4.3.4 restored the behaviour of PHP 3 which only regards a function a constructor if it's of the same name as the class which has been called. So instead, I'm confronted with
I am a regular function named B in class A.
I am not a constructor in A.
which is quite irritating.

The reason I'm telling this is I wrote some classes which relied on the PHP 4 behaviour, however because of the change it failed to work. Tracking down the error I came to that surprising result.

Platform: Linux 2.4.22, PHP 4.3.4 as Apache module, Apache 2.0.48.
Some PHP settings:
allow_call_time_pass_reference Off
allow_url_fopen	On
always_populate_raw_post_data	Off
arg_separator.input	&
arg_separator.output	&
asp_tags	Off
auto_append_file	no value
auto_prepend_file	no value
browscap	no value
default_charset	no value
default_mimetype	text/html
define_syslog_variables	Off
disable_classes	no value
disable_functions	no value
display_errors	On
display_startup_errors	Off
doc_root	no value
docref_ext	.html
docref_root	/php-manual/
enable_dl	On
error_append_string	no value
error_log	no value
error_prepend_string	no value
error_reporting	2047
expose_php	On
extension_dir	/usr/lib/php4
file_uploads	On
gpc_order	GPC
highlight.bg	#FFFFFF
highlight.comment	#FF8000
highlight.default	#0000BB
highlight.html	#000000
highlight.keyword	#007700
highlight.string	#DD0000
html_errors	On
ignore_repeated_errors	Off
ignore_repeated_source	Off
ignore_user_abort	Off
implicit_flush	Off
include_path	.:/usr/include/php
log_errors	Off
log_errors_max_len	1024
magic_quotes_gpc	Off
magic_quotes_runtime	Off
magic_quotes_sybase	Off
max_execution_time	15
max_input_time	15
memory_limit	16M
open_basedir	/home/httpd/
output_buffering	no value
output_handler	no value
post_max_size	8M
precision	14
register_argc_argv	Off
register_globals	Off
report_memleaks	On
safe_mode	On
safe_mode_exec_dir	no value
safe_mode_gid	Off
safe_mode_include_dir	no value
sendmail_from	me(at)localhost(dot)com
sendmail_path	/usr/sbin/sendmail -t -i
serialize_precision	100
short_open_tag	Off
SMTP	localhost
smtp_port	25
sql.safe_mode	Off
track_errors	Off
unserialize_callback_func	no value
upload_max_filesize	2M
upload_tmp_dir	/home/httpd/phptemp
user_dir	no value
variables_order	EGPCS
xmlrpc_error_number	0
xmlrpc_errors	Off
y2k_compliance	On

Just in case it has something to do with my configuration. Is there a way to restore the former PHP 4 behaviour?

Olliver

[Updated on: Tue, 18 November 2003 09:52]

Report message to a moderator

Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: how can I produce a 3des string?
Next Topic: ob_start, ob_gzhandler
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Oct 19 03:27:17 EDT 2017

Total time taken to generate the page: 0.00621 seconds