Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:50:13+00:00 2026-05-29T19:50:13+00:00

I am a newbie at PHP; today I see some code as the following

  • 0

I am a newbie at PHP; today I see some code as the following in Magento top.phtml.

<?php $_menu = $this->renderCategoriesMenuHtml(0,'level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
    <ul id="nav">
        <!--NEW HOME LINK -->
        <li class="home"><a href="<?php echo $this->getUrl('') ?>"><?php echo $this->__('Home') ?></a>"</li>
        <!--NEW HOME LINK -->
        <?php echo $_menu ?>
    </ul>
</div>
<?php endif ?>

I know $this is the self of the class, it’s only used in the class to refer to the method or property, on the above code, there is no class has been defined, why it can use $this keyword directly? What does $this->__('Home') stand for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:50:17+00:00Added an answer on May 29, 2026 at 7:50 pm

    Since you tagged this magento you likely have a class like Mage_Catalog_Block_Navigation. At least, the methods hint at that. Now, I have no clue about Magento, but this class extends from Mage_Core_Block_Template and in that class you have the fetchView Method, which at some point does

    include $includeFilePath;
    

    When you include code inside a method, you do have access to $this in the included file code, because it is evaluated in the scope of that instance:

    When a file is included, the code it contains inherits the variable scope of the line on which the include occurs. Any variables available at that line in the calling file will be available within the called file, from that point forward. However, all functions and classes defined in the included file have the global scope.

    General Example:

    class Template
    …
        public function render($templateFile)
        {
            include $templateFile;
        }
        public function ___($stringToTranslate)
        {
            // translates $stringToTranslate somehow
        }
     }
    

    Note that “$this is not the self of the class” is only partially correct. self is also a keyword and php, but while self really refers to the class, $this refers to the instance of a class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i am a newbie to php and am following this tutorial http://tutorialpot.com/2011/06/fancy-contact-form-with-inline-validation/#comment-1771 i
I'm a fairly newbie php coder, got this php code in a tutorial to
I'm completely newbie in PHP. I have tried example code from this site .
I am a newbie to PHP development. I tried following code sample from PHP5
I'm a PHP newbie working a some scripts to display some news articles from
I'm a real newbie with php and MySQL. Now I'm working on the following
I'm a total newbie and want to start with php. I know some javascript
I am newbie to php and so please do not mind me asking this
I am newbie to PHP I have written the following program: $address=array('abc@gmail.com','abc@hotmail.com','def@yahoo.com'); foreach($address as
I'm a newbie with PHP so this might be ridiculously easy question, but despite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.