For smart Primates & ROBOTS (oh and ALIENS ).

Blogroll

Saturday, October 05, 2013

namespace in php

namespace in php

<?php
namespace foo;
class Robot {
    static function says() {echo 'I am Terminator!';}
    }
?>
  
<?php
namespace bar;
class RoboCop {
    static function says() {echo 'I am Robocop!';}
    }
?>
  
<?php namespace terminate;
    class Terminator {
    static function says() {echo 'Terminator';}  }
?>

<?php namespace computer;
    class Comp {
    static function show() {echo 'I am computer';}
    function laptop() { echo "this is laptop ";}
    }
?>

  
<?php

namespace realexample;
//use foo as robo;
//use bar as roboc;
//use terminate;
//echo robo\Robot::says(), "<br />\n";
//echo roboc\RoboCop::says(), "<br />\n";
//echo terminate\Terminator::says(), "<br />\n";


echo \foo\Robot::says(), "<br />\n";
echo \bar\RoboCop::says(), "<br />\n";
echo \terminate\Terminator::says(), "<br />\n";
echo \computer\Comp::show(), "<br />\n";
$comp = new \computer\Comp();
$comp->laptop();
 

  ?>


Share:

0 comments:

Post a Comment

How to make center align child div

 How to make center align child div?   Suppose you have 2 Div tag. And want the make inner tag center <div id="d1">      ...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive