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

Add Dependent Scripts

   here is the code that allow to add dependent script :         <script>         const addDependentScripts = async function( scriptsT...

Ads Inside Post

Powered by Blogger.

Arsip

Blog Archive