Skip to main content

Posts

Showing posts from May, 2011

Smarty section and foreach

A  {section}  is for looping over  sequentially indexed arrays of data , unlike foreach ,  which is used to loop over a  single associative array .  Example:  $data = array(1000,1001,1002); $smarty->assign('custid',$data); { section loop =$custid name =customer} id: {$custid[customer]}<br /> {/section} A {foreach}  is used to loop over an  associative array  as well a numerically-indexed array, unlike section, which is for looping over  numerically-indexed arrays only .  Example: $arr = array(1000, 1001, 1002); $smarty->assign('myArray', $arr); <ul> { foreach from =$myArray item =foo}     <li>{$foo}</li> {/foreach} </ul>

Differences between php4 and php5

These are some of the differences i know between php4 and php5: 1. PHP5 supports more oops concepts like access specifiers and inheritance 2. we can pass objects by reference in php5 (using clone keyword) 3. Exception class included in PHP5 (try and catch) 4. More XML related functions like SimpleXML were included in PHP5 for easy  processing of XML data 5. PHP4 uses Zend engine 1.0 as a parser.PHP5 uses Zend engine 2.0 6. php 5 has improvements in design, security and stablity 7. Magic methods have been included in php5 8. Unified Constructors and Destructors in php5 9. There is a new error level defined as E_STRICT in php5  (notifies deprecated code) 10. Final keyword in php5 indicates that a method cannot be overridden by a  child Note: It is said that PHP5 has Backward compatibility issues with php4.