Forum Moderators: coopster
<?php
error_reporting(E_ALL | E_STRICT);
Class foo{
//var declarations here
.
..
.
//Start functions... include relevent files
function __constructor(){
if(file_exists("../control/control.php")){
include("../control/control.php");
}
else{
echo "<div>Warning, controller file is missing</div>";
exit;
}
return $control;
}
Then from this point inside the class I refer to the array
function __construct(){
$ctrl = CONTROL_FILE;
$err=null;
if (file_exists($ctrl)){
include($ctrl);
return $this->control = $control;
}
else{ $err = "No control file"; }
return $this->error = $err;
}
class myClass{
private $id;
public function __construct($i){
$this->id = $i;
}
public function getID(){
return $this->id;
}
public static function doSomthing(){
return "I don't need a class";
}
}
$o = new myClass(1);
echo $o->getID();
echo myClass::doSomething();
public class myClass{
static $count = 0;
public function __construct(){
self::$count++;
}
}
function __construct() {
$ctrl = CONTROL_FILE;
$err=null;
if (file_exists($ctrl)) {
include($ctrl);
return $this->control = $control;
}
else { $err = "No control file"; }
return $this->error = $err;
} class MyClass {
public $error = false;
public function __construct() {
// Initialise some stuff...
// But something is wrong...
$this->error = true;
}
}
$myObject = new MyClass();
if ($myObject->error) {
// An error occurred!
}
[size=2]class MyClass {
public $error = false;
[b]public $control;[/b] //define var in correct php way ;)
public function __construct() {
if(file_exists(PATH_TO_FILE."control.php")){
include(PATH_TO_FILE."control.php");
[b]$this->control = $control;[/b]//assign array name to declared class var
}else{
// But something is wrong...
$this->error = true;
}
}
}[/size]
class MyClass {
public $error = false;
public function __construct() {
// Initialise some stuff...
// But something is wrong...
return false;
}
}
$myObject = new MyClass();
if ($myObject == false) {
// This NEVER happens, because $myObject is an object, not (bool)false
}