|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-08-11 13:33 UTC] onebird at 21cn dot com
Description:
------------
construct Class error when used 2 parameters or more ;
The first parameter can't used the Default value !!
Reproduce code:
---------------
class Base
{.....}
class system_login extends Base
{
var $db_conn;
var $user_table = 'user';
function system_login( $DB = "", $mode = "http" )
{.....}
}
$a = new system_login ("","Form");
Expected result:
----------------
I found the $mode == "http" always ;
but it will be $mode == "Form" when construct this class;
if I used : $a = new system_login ("ss","Form");
the $mode == "Form" is OK!
The first parameter can't used the Default value !!
this code can used under PHP4 , it OK always !
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 03:00:02 2025 UTC |
More for code : // file base.inc <?php class Base { var $test; var $info; function test() { //...anything.. } } ?> //this is other file <?php require_once("base.inc"); class system_login extends Base { private $db_conn; private $user_table = 'user'; function system_login( $DB = "", $mode = "http" ) { global $Global_DB_Connection; if (empty($DB)) $this->db_conn = $Global_DB_Connection; else $this->db_conn = $DB; if ($mode == 'http') { if (!isset($_SERVER['PHP_AUTH_USER'])) { header('WWW-Authenticate: Basic realm="My Realm"'); header('HTTP/1.0 401 Unauthorized'); echo 'please login at first !'; exit; } else { Base::sys_login($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']); // ...anything.. } } else { //... something for Form submit to login ... } } } $a = new system_login ("","Form"); ?> if changed the : function system_login( $DB = "", $mode = "http" ) to function system_login( $DB, $mode ) used the $a = new system_login ("","Form"); or $a = new system_login ("",""); The PHP5 told me all the parameters missing !!