Jump to content

reidel

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

reidel's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks a lot everyone. It makes more sense to me now! Also, I've been reading up on CodeIgniter's Docus and they're really good material for both beginners and advanced users. Something about data Routing and Output Processing gave me some clues, but Nightslyr's answers really put the spot light on. Thanks again Nightslyr and sunfighter!
  2. I believe this is what Nightslyr mean by creating and using object instances rather than class definitions: Class definitions are where you define an object. An object instance is an instance of a class or data type, in this case an instance of your class. include('Tons of files included here'); $myarray = array( 0 => array("question" => "answer"), 1 => array("question1" => "answer1") ); class BigClass { var $a var $b function fiststep(){ global $myarray; foreach($myarray as $anarray) { $this->$anarray = new includedfunction1($anarray["question"]); $this->$anarray->Values = array(array("yes", "yes"), array("no", "no")); $this->$anarray->Multiple = true; } } function nthstep(){ global $myarray; $myarray = $myarray; foreach($myarray as $anarray) { $this->$anarray->astep(); } } }//definition of the class BigClass ends here $objectInstance = new BigClass; //once you've created the object instance of BigClass only then can you use the functions of BigClass $objectInstance->nthstep(); include('Tons of files included here'); Take note: This method still uses the global variable. Preferably do this: ... //long code definition function nthstep($myarray){ $myarray = $myarray; foreach($myarray as $anarray) { $this->$anarray->astep(); } return $myarray; } ... //other code you need to put
  3. First off, I'm pulling from a hat that's been more used to strongly typed languages for the duration that its been on my head, so correct me if I'm wrong. Wouldn't it be much easier to have passed on your variables as arguements to functions rather than using it as a global instance? There's less chance of altering a needed dataset for the next operation. So instead of modifying AND using your global variable using functions that require the instance at moment of function call, simply have the function return a new value that you can affix to your original variable.
  4. I come from a long line of down to earth, hard-up, and linear programmers and I've been introduced to the wonders of web. But now I'm a bit lost. Okay, I know much about programming concepts with experience with C++, C#, and assembly, but I can't seem to tame PHP. I've written some code to act as a sort of framework in the spirit of the M-V-C pattern, but I don't know what's happening to my instantiations! I've been reading up on the help files, documentations, and looking up excellent code, but I still don't know what's happening. I'm totally in the dark. Can someone point me to the light? I create my includes (global variables), and local variables, and even classes, but I seem to lose the instantiation of these objects when I navigate more than three pages from my index. What's happening and how do I avoid this?
  5. reidel

    Hi Guys!

    I'm pretty new to both this community and PHP (well, to web programming for that matter!). It's a totally different species to me.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.