FAQ |
Kalender |
![]() |
#1 | ||
|
|||
Nykomling
|
Vi säger att vi har denna classen :
Kod:
class DB { var $host; // The hostname var $user; // The username var $password; // The password var $database; // The database function DB($host,$user,$password,$database) // PHP4 class constructor { // populate the properties thats needed for connection $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; } // lite andra metoder } då kan man ju göra såhär Kod:
class DB { var $host; // The hostname var $user; // The username var $password; // The password var $database; // The database function DB($host,$user,$password,$database) // PHP4 class constructor { // populate the properties thats needed for connection $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; } function __construct($host,$user,$password,$database) // PHP5 class constructor { { $this->DB($host,$user,$password,$database); } // lite andra metoder } Kod:
class DB { var $host; // The hostname var $user; // The username var $password; // The password var $database; // The database function DB($host,$user,$password,$database) // PHP4 class constructor { // populate the properties thats needed for connection $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; } function __construct($host,$user,$password,$database) // PHP5 class constructor { // populate the properties thats needed for connection $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; } // lite andra metoder } Och ska man ta med PHP 5s construct och göra så att prestandan sjunker för PHP 4 användarna eller ska PHP 5 användarna få sämre prestanda ( då kör man utan PHP 5s construct |
||
![]() |
![]() |
|
|