Friday, December 30, 2011

Simple function overloading in php

<?php
class hello
{
var $id;
 var $edi;
 function hello()
 {
 $this->id="1234";
 $this->edi="abc";
 }

public function display()
{
echo $this->id;
echo $this->edi;
}

}
class hello1 extends hello
{

 function display($a,$b)
{
hello::display();
echo "</br>";
echo $this->id=$a;
echo $this->edi=$b;
}

}
$obj=new hello;
$obj1=new hello1;
$obj1->display("a","b");


?>
output
1234abc
ab

Friday, December 9, 2011

Enable Template Path Hints for Magento Admin, Enable Template Path Hints in Magento Admin

Step 1: Change the file app/code/core/Mage/Core/etc/system.xml as follows:
In the system.xml change the value of tag from 0 to 1.
Step:2
Enable the Template path hints and blocks from the admin panel.

Now you will be able to see the red lined path in the admin.

Php Code to explore every directory and files in a path

<?php

calldir("lightbox");
function calldir($path)
{
if ($handle = opendir($path)) {
    echo "Directory handle: $handle</br>";
    echo "Files:</br>";
     $i=0;
    /* This is the correct way to loop over the directory. */
    while (false !== ($file = readdir($handle))) {
        echo "$file</br>";
  $data=explode(".",$file);
  if($data[1]==''&& $file!="." && $file!="..")
  {
  if (is_string($data[0]))
   {
  //echo $file.'</br>';
  $url=$path.'/'.$file;
  calldir($url);

  }
  }
    }

  
    closedir($handle);
}
}
?>