RE: (Need help) Beginner's question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sachin Raut am Donnerstag, 31. Juli 2014 - 10:03:
> Hi
> 
> I have a question in this following code.
> <?php
> 
> class A
> 
> {
> 
>     public $country;
> 
>      function __construct($data=array())
> 
>     {
> 
>        if(!isset($data))
> 
>        {
> 
>        trigger_error("Couldn't construct address with a ".get_class());
> 
>        }
> 
>     }
> 
> }
> 
>  $obj=new A();
> 
> ?>
> 
> I am not sending any "array" as an argument while creating an object. And
> hence "if statement" in constructor should have been executed, but it
> displays blank page. My query is why it's not executing "if statement"?
> 
> Thanks
> Sachin
> 
Hi,
because $data is set! In your argument in the constructor: $data = array()!
try if(count($data) == 0)...
Niklaus

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux