0

What does this code do in magento ?

 $customer = $this->_getCustomer();

this code in createPostAction in customer/accountController .

Why put underscore "_" in most of Method

1
  • 1
    just check '_getCustomer()' method of that class or its parent class,for your answer._ is nothing special here. Commented Dec 12, 2014 at 9:39

2 Answers 2

1

This function gets the current user data. @return Mage_Customer_Model_Customer

I believe functions with _ at the start are private. Public functions do not have an underscore.

See: http://doc-magento.com/nav.html?_functions/index.html

3

The underscore prefix is part of the Zend Framework 1 coding standards (and thus the Magento 1.x coding standards) that every private or protected method or property name should start with an _.
This goes back to the php version 4 days, when there where objects but only public visibility.

Nowadays with php5 there is no real reason to proliferate this convention, except that it is part of the Magento coding standard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.