This blog is about PHP in general. It tackles various topics related to the language itself especially at the OOP level, discusses various topics related to Zend Framework and shares my experience with Cake PHP. I believe that mastering technology is heavily based on one's ability to discuss its details and share knowledge with others. Technology is a wide wild world after all!
victor | 16 November, 2010 07:24
All Object Oriented languages (or almost all of them) support function overloading where programmers are allowed to define multiple functions with the same name but with separate "function signatures". A function signature is usually the number of parameters, the order of parameters and / or the type of parameters.
For example, in Java, you are allowed to define the following:
public void testFunction (int x) { ... }
public void testFunction (int x, int y) { ... }
public void testFunction (int x, double y) { ... }
By defining the above, the Java Virtual Machine will automatically invoke the appropriate function once called based on the number and type of parameters given. For example, invoking
testFunction (2);
will automatically invoke the first function while invoking
testFunction (2, 3.1);
will automatically invoke the third function.
PHP, on the other hand, does not have support for function overloading yet. Defining the same function more than once with a different number of paramters will surely (so far) generate an error at the parser level.
It is still possible to simulate function overloading in PHP using parameters default values. Upon function definition, simply provide default values to parameters as follows:
function testFunction ($a = false, $b = false, $c = false) { .... }
By doing so, you will be defining a function that takes 3 arguments ($a, $b, and $c) whose default value is false.
Within the function body, you will then simply check whether the value of the parameter that is being passed is still false and act accordingly.
Remember, though, that PHP provides automatic data type conversion. In other words, if the value of $b is 0 (Zero) and you check whether $b is false using the equality operator (==), you will get a true value returned. As such, remember to use the data typed equality operator (===) instead of the normal operator (==).
victor | 22 February, 2010 09:20
Autoloading is the process of automatically loading classes when needed wthout having to go through the traditional include() and require() directives. This helps PHP developers work without having to worry about whether the class that they need has already been loaded or not.
To achieve this, PHP 5 provides the __autoload() magic method that is called automatically whenever a class / object is being referenced while not being defined. If a definition exists for that class, the magic method will not be invoked. If a definition does not exist, the __autoload() method will be invoked before giving up and generating a warning / error message.
So how does auto loading work in examples?
victor | 21 February, 2010 01:33
My first really mini-article will be simply a definition of the 3 topics behind this blog.
PHP is a widely used, general-purpose web scripting language that is embedded into the HTML source document and interpreted by a web-server integrated PHP processor module.
The name "PHP" is a recursive acronym that stands for "PHP Hypertext Preprocessor". PHP code can be also processed by an interpreter application in command-line mode to perform desired operating system operations. It may also function as a graphical application through the integration of a windowing toolkit (like PHP GTK).PHP is available as a processor for most modern web servers and as standalone interpreter on most operating systems and computing platforms.
Zend Framework (ZF) is an open source, object-oriented web application framework implemented in PHP 5. ZF is a use-at-will framework.
There is no single development paradigm or pattern that all Zend Framework users must follow, although ZF does provide components for the (Model View Controller paradigm) MVC, Table Data Gateway, and Row Data Gateway design patterns. Zend Framework provides individual components for many other common requirements in web application development.
CakePHP is an open source web application framework for producing web applications. It is written in PHP and is compatible with PHP 4 and PHP 5.
CakePHP makes it easier for the user to interface with the database with the active record pattern. It also encourages the use of the MVC architectural pattern and provides cool features like integrated CRUD for datasource interaction, application scaffolding, built-in validation, data sanitization, and internationalization and localization, various behaviors, components and helpers to minimize development time, as well as unit testing using the SimpleTest framework.
PHP, Zend Framework and CakePHP are all available through open-source licenses that allow for their free usage (although dontaion is highly recommended to maintain them) and that provide complete access to the source code behind them. More detailed topics pertaining to specific characteristics of these technologies will be provided in future articles.
victor | 21 February, 2010 01:24
| « | January 2012 | » | ||||
|---|---|---|---|---|---|---|
| Su | Mo | Tu | We | Th | Fr | Sa |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||
I am experienced in Internet technologies, Web Services and Online Interactive solutions. I am very interested in challenges related to web services engineering especially complex and hybrid online solutions (Intranet, Extranet, e-Commerce, etc.) and algorithms (search engines, security, etc.)
I am experienced in security as well. My expertise is mainly in network and Internet security. I am also experienced in the fields of cryptography, security assessment techniques, security design (policies, profiles, architectures, etc.) as well as security auditing and ethical hacking.
I am a Linux fan (by nature :). Period.