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

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights

Unable to resolve <website url> Try checking the for validity Google Pagespeed Insights   You have a website and want to test it'...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive