Namespace

 <?php

// THIS IS INDEX FILE

require "products.php";
require "testing.php";

function wow()
{
    echo "Wow from Index File". "<br>";
}

$object = new test\Product();
$object = new pro\Product();

wow() . "<br>";
pro\wow() . "<br>";
?>
//  OUTPUT:
// This is testing page class
// This is product Class
// This is testing page class
// Wow from Index File
// Wow from Product File


<?php
//  THIS IS TESTING FILE

namespace test;

class Product
{
    public function __construct()
    {
        echo "This is testing page class" . "<br>";
    }
}
?>



<?php
//  THIS IS PRODUCTS FILE

namespace pro;

class Product
{
    public function __construct()
    {
        echo "This is product Class" . "<br>";

        $test = new \test\Product();
    }
}
function wow()
{
    echo "Wow from Product File" . "<br>";
}

?>

//  OUTPUT:
// This is testing page class
// This is product Class
// This is testing page class
// Wow from Index File
// Wow from Product File

Comments

Popular posts from this blog

Logical_Operators

SubQuery with EXISTS and NOT EXISTS in PHP

Get Functions