Yesterday I was playing with Magento. Checking out the source code (methods, classes). I found an interesting class called Mage_Core_Model_Config_Options. Interesting because of the way you call methods from it.
To be honest, I did not know that one can store string name into the variable and if that name is the same as the name of some method inside the class you can call that method using that variable like
$this->$variableName();
Notice the brackets at the end. This is what tells the PHP to treat this as method. Cool, right?
Here is a sample code I wrote for you to see what I’m talking about.
Magento, PHP
Magento, PHP
I am working on a project that has a lot of user input forms. Forms are used to submit entries to MySQL database. Submitting values to forms and processing them trough some PHP logic is no news for PHP.
The problem I encountered while developing my application was the mapping of values from database to $_POST variables and vice verse. This may not sounds like a that big of a deal but when you have more than a dozen of functions returning array of information that needs to be edited trough forms that mapping all those can be a overkill task. Read more…
PHP
binding, form, PHP
I have been using FireBug for some time now. Although his prime purpose is for JavaScript debugging I use it mostly for fast drilling down to CSS stuff. I just love the possibility to change, delete or add CSS properties on HTML document on the fly. Anyway I like FireBug. In absence of one for all IDE it’s quite decent solution for debugging.
Contrast to JavaScript development I do a lot of PHP development. Sadly to say, I am hugely disappointed to PHP debugging solutions. I know there are few solutions out there like XDebug but they are simply no match to Microsoft’s Visual Studio debugger. Anyhow, a free is a free so be grateful. Read more…
CodeIgniter, PHP
CodeIgniter, debugg, FirePHP, PHP
Programming PHP the right way as with any other OOP language requires knowledge and understanding of OOP concepts. For those of you who don’t know this by now, OOP stand for Object Oriented Programming. Working on a small project where developer goes trough just a few files is a no problem since your most likely memorize all your properties and methods.
However, working with big project like Magento, or even WordPress can become real pain in a neck if u use only text editor trough your development process. On the other hand, don’t think your off the hook using some fancy IDE studio like NetBeans, NuSphere, or ZendStudio. Problem is that each of them has it’s own problems and glitches resolving object context across multiple project files and so on. Sometimes when you hit $this-> code completion wont return any methods that go with it. So what do you do? Read more…
PHP
OOP, PHP
Strange function names. Strange, silly, stupid and so on. Call them whatever and however you want. As to my knowledge, PHP originally had function names combining multiple words as one like “dosomeactionfunction()”. With time, community realized this is not so good practice so they decided using underscored function names like “do_some_action_function()”. Personally I hate underscored names both for functions and for variables. I’m a fan of camel caps convention popular in object oriented programming. With camel caps your function names got written like “doSomeActionFunction()”. If nothing else it’s shorter.
Absence of namespaces. PHP 4 already introduced some object oriented concepts, but PHP 5 was the big brother, the one promising the object oriented support fully. Again, personally, I think it’s funny and impractical seeing object oriented programming language without some sort of a good namespace support. I hate includes, requires, and auto includes and so on. You get the picture. Read more…
PHP
PHP
Recent comments