Strict Standards: Creating default object from empty value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Rupo
Forum Commoner
Posts: 25
Joined: Thu Jul 05, 2007 11:22 am

Strict Standards: Creating default object from empty value

Post by Rupo »

Hi,

what's going wrong in my liitle test script and how can i fix it

Code: Select all

Strict Standards: Creating default object from empty value in E:\xampp\htdocs\test.php on line 23
object(stdClass)#2 (1) { ["text"]=> string(17) "Neue news anlegen" }

Code: Select all

class LeftMenues
    
    {
    public $_mnuPageObject;
    public function __construct($baseUrl)
        
        $array=array
            (
            "step" => "menue",
            "link" => $baseUrl . "/admin/menu-add",
            "alt" => "neue News anlegen",
            "text" => "Neue news anlegen"
            );

        $this->AddMenuPageObject($array);
        }

    public function AddMenuPageObject($array)
        {
        $this->_mnuPageObject->text=$array["text"];
        }
		
    public function ReturnMenuPageObject()
        {
        return $this->_mnuPageObject;
        }

    }  
$foo=new LeftMenues('');
var_dump($foo->ReturnMenuPageObject());
Regards
Mic
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

This thread appears to have nothing to do with PHPClasses.org. :?

$_mnuPageObject was never initialized.
User avatar
Stryks
Forum Regular
Posts: 746
Joined: Wed Jan 14, 2004 5:06 pm

Post by Stryks »

Well .... you seem to be missing a opening curly brace on the construct function.

Try ...

Code: Select all

	public function __construct($baseUrl) {
	   
		$array=array
			(
			"step" => "menue",
			"link" => $baseUrl . "/admin/menu-add",
			"alt" => "neue News anlegen",
			"text" => "Neue news anlegen"
			);

		$this->AddMenuPageObject($array);
		}
Post Reply