Solved

Copy array in a class

Posted on 2013-01-17
1
238 Views
Last Modified: 2013-01-17
Ok, as your probably aware Im new to OOP in PHP, so trying to figure things out one at a time.

Im trying to pass an array into a constructor, and copy that array into a variable in the class, so I can use it in another function, so to test:-

class protoMenu{
    private $menuArray;
    function protoMenu($arrMenu) {
        $menuArray = $arrMenu;
        $this->drawMenu();
    }

    private function drawMenu() {
        var_dump($menuArray);
    }
}

$Menu = new protoMenu(array("divContentsID" => "divMenuContents", "divMenuID" => "divMenu"));

Open in new window


Looking at array copying Im doing everything right, but its not working
0
Comment
Question by:tonelm54
1 Comment
 
LVL 34

Accepted Solution

by:
gr8gonzo earned 500 total points
ID: 38789442
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now