php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29613 construct Class error when used 2 parameters or more
Submitted: 2004-08-11 13:33 UTC Modified: 2004-08-31 01:00 UTC
From: onebird at 21cn dot com Assigned:
Status: No Feedback Package: Scripting Engine problem
PHP Version: 5.0.0 OS: win2k
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: onebird at 21cn dot com
New email:
PHP Version: OS:

 

 [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 !


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-11 13:41 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc.

If possible, make the script source available online and provide
an URL to it here. Try avoid embedding huge scripts into the report.
 [2004-08-11 16:49 UTC] onebird at 21cn dot com
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 !!
 [2004-08-11 17:00 UTC] onebird at 21cn dot com
if I used an object to $DB , like :
$a = new system_login ($Global_DB_Connection, "Form");
I found the "Form" can't transfer to $mode also !
 [2004-08-23 08:09 UTC] tony2001@php.net
Can't reproduce it with your code. Works fine.
 [2004-08-31 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC