Jump to content

"$this" outside classes? Someone explain...


Recommended Posts

I'm just starting to learn OOP and frameworks, and I read this (http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf) Zend framework tutorial, and it uses "$this" all over the place. Isn't "$this" supposed to be used inside classes to refer to the class it's in? If you, for example, go to the bottom of page 12 in that tutorial, "$this" is used right at the beginning of a new file. Is that entire .phtml file somehow inside a class? I'm confused...

Link to comment
https://forums.phpfreaks.com/topic/200057-this-outside-classes-someone-explain/
Share on other sites

    /**
     * Includes the view script in a scope with only public $this variables.
     *
     * @param string The view script to execute.
     */
    protected function _run()
    {
        if ($this->_useViewStream && $this->useStreamWrapper()) {
            include 'zend.view://' . func_get_arg(0);
        } else {
            include func_get_arg(0);
        }
    }

Yeah. I just googled "ViewRenderer" and found this announcement from its developer, from 2007: http://devzone.zend.com/article/2072

 

Anyway, thanks for your help, man. This has cleared up my confusion a bit. I don't have any more questions right now, but I'll go find some more tutorials, and then I'll undoubtedly be back with more questions later. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.