Re: problems accesing an object via globals
| From: | julian | Date: | Mon, 03 Dec 2007 09:52:22 +0000 |
| Subject: | Re: problems accesing an object via globals | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-265406@lists.php.net to get a copy of this message | ||
however this will work...
p1.inc
1 <?php
2
3 class dbb{
4
5 var $var=10;
6
7 function fun2(){
8 return $this->var;;
9 }
10 }
11
12 class obj {
13 var $obj2=20;14
15 function f1(){
16 global $db;
17
18 echo "\n".$db->fun2()*$this->obj2."\n"; 19 }20 } 21 ?> 1 #!/usr/bin/php -q 2 3 <?php 4 5 require_once('p1.inc'); 6 7 $db= new dbb(); 8 9 10 $obj = new obj(); 11 12 $obj->f1(); 13 14 ?>