Коментарии

Автор:
The keyword 'use' has two different applications, but the reserved word table links to here.

It can apply to namespace constucts:

file1:
<?php namespace foo;
  class 
Cat 
    static function 
says() {echo 'meoow';}  } ?>

file2:
<?php namespace bar;
  class 
Dog {
    static function 
says() {echo 'ruff';}  } ?>

file3:
<?php namespace animate;
  class 
Animal {
    static function 
breathes() {echo 'air';}  } ?>

file4:
<?php namespace fub;
  include 
'file1.php';
  include 
'file2.php';
  include 
'file3.php';
  use 
foo as feline;
  use 
bar as canine;
  use 
animate;
  echo 
felineCat::says(), "<br />\n";
  echo 
canineDog::says(), "<br />\n";
  echo 
animateAnimal::breathes(), "<br />\n"?>

Note that 
felineCat::says()
should be
\feline\Cat::says()
(and similar for the others)
but this comment form deletes the backslash (why???) 

The 'use' keyword also applies to closure constructs:

<?php function getTotal($products_costs$tax)
    {
       
$total 0.00;
       
       
$callback =
            function (
$pricePerItem) use ($tax, &$total)
            {
               
               
$total += $pricePerItem * ($tax 1.0);
            };
       
       
array_walk($products_costs$callback);
        return 
round($total2);
    }
?>
2011-05-25 14:06:14
http://php5.kiev.ua/manual/ru/language.namespaces.html
Автор:
<?php 
// multiple namespaces in a single file:

namespace foo{
  class 
Cat 
    static function 
says() {echo 'meoow';}  } 
}

namespace bar{
  class 
Dog {
    static function 
says() {echo 'ruff';}  } 
  class 
Cat 
    static function 
says() {echo 'meowi';}  } 
  class 
Mouse {     //nonstatic function
   
function says() {echo 'Come and get me ;)';}  } 
}

namespace animate{
  class 
Animal {
    static function 
breathes() {echo 'air';}  }
}

namespace{        // No Namespace: global code
 
use foo as feline;
  use 
bar as canine;
  use 
barMouse as MouseOnly;
  use 
animate;
  echo 
animateAnimal::breathes(), "<br />\n"
  echo 
felineCat::says(), "<br />\n"//not starting with a slash!
 
echo canineCat::says(), "<br />\n";
  echo 
canineDog::says(), "<br />\n";
 
//any of the three following lines work:
  // $micky=new bar\Mouse();
  // $micky=new canine\Mouse();
 
$micky=new test();
  echo 
$micky->says();
}
?>
2015-01-22 15:13:37
http://php5.kiev.ua/manual/ru/language.namespaces.html
In addition to using namespaces and closures, the use keyword has another new meaning as of PHP 5.4 - using traits:

<?php
trait Hello 
{
    public function 
sayHello() {
        echo 
'Hello ';
    }
}

trait World {
    public function 
sayWorld() {
        echo 
'World';
    }
}

class 
MyHelloWorld {
    use 
HelloWorld;
    public function 
sayExclamationMark() {
        echo 
'!';
    }
}

$o = new MyHelloWorld();
$o->sayHello();
$o->sayWorld();
$o->sayExclamationMark();
?>

More info here: language.oop5.traits
2015-03-26 19:04:50
http://php5.kiev.ua/manual/ru/language.namespaces.html
here is a simple example to use namespace

<?php

namespace appa
{
    class 
one{
       public static function 
_1(){
        echo 
'a one _1<br>';
       }
    }
}

namespace appb{
    class 
one{
        public static function 
_2(){
            echo 
'b one _2<br>';
        }
    }
}

namespace app{

    echo 
aone::_1();
    echo 
bone::_2();
    echo 
atwo::_1();
}

namespace appa{
    class 
two{
       public static function 
_1(){
        echo 
'a two _1<br>';
       }
    }
}

prints 
a one _1
b one _2
a two _1
2015-12-27 20:43:12
http://php5.kiev.ua/manual/ru/language.namespaces.html
Автор:
Tested on PHP 7.0.5, Windows
The line "use animate;" equals the line "use animate as animate;"
but the "use other\animate;" equals "use other\animate as animate;"

file1:
<?php namespace foo;
  class 
Cat 
    static function 
says() {echo 'meoow';}  } ?>

file2:
<?php namespace bar;
  class 
Dog {
    static function 
says() {echo 'ruff';}  } ?>

file3:
<?php namespace otheranimate;
  class 
Animal {
    static function 
breathes() {echo 'air';}  } ?>

file4:
<?php namespace fub;
  include 
'file1.php';
  include 
'file2.php';
  include 
'file3.php';
  use 
foo as feline;
  use 
bar as canine;
  use 
otheranimate;       //use other\animate as animate;
 
echo felineCat::says(), "<br />\n";
  echo 
canineDog::says(), "<br />\n";
  echo 
animateAnimal::breathes(), "<br />\n"?>
2016-05-10 11:15:07
http://php5.kiev.ua/manual/ru/language.namespaces.html
The man who does not drink and does not eat meat is incredible!

After reading this sutra, I'm going to quit drinking and eat vegan.

    Excerpt from the "Generous Guang Hua Yan ten Evil Products Sutra":

    Kasyapa Bodhisattva White Buddha said: The Buddha, only the Tathagata for me to explain, do not drink, not meat eaters, how many blessings?

    Buddha-Gloucester:
    If someone, like horse cattle and sheep, glass treasures ying Luo, the country city wife, holding with giving, still less than some people can break wine meat, millions not better than one.

    Replacement is a matter, if someone Bechi gold over 3,000 of the world, holding the use of alms, still less than someone can break wine meat, millions less than one.

    The replacement is a matter, if there is the ability to cast gold for hundreds of, holding the use of giving, still less than some people can break wine meat, millions less than one.

    The replacement is a matter, if someone artificial fan Hua Bao lid, all over the 3,000 world, still less than someone can break wine meat, millions.

    The replacement is a matter, if there are man-made large pagoda, eaves eaves, such as rice hemp Bamboo reed, up to Brahma, as someone can break the wine meat, millions less than the first.

    A good man, not a carnivore, an earthly Bodhisattva, is an extraordinary husband. 
    Editor's note: The front content can be seen, even if a person who does not learn Buddha, can insist on eating the whole vegetarian, Ford has boundless. Let's all go vegetarian.

All eggs are not edible, there are children also

  Someone asked the people of Xuanhua: "Why can't vegetarians eat eggs?" "

    The venerable Master said, "No Man or woman (a rooster or a hen) can hatch a chicken." The former people do not understand this truth, he said no, and there is no evidence. The man who eats eggs why does he say such a theory? Is that he wants to eat eggs. Eggs, whether or not a rooster will have chicks, will not be born. "Leng Yan Jing" said: "Eggs only want to live." "Above is the words of the master Xuan Hua is absolutely wrong." After the lying of the man in Xuanhua, he burned more than 4,000 relics to show his life not to play half a sentence of Sakyamuni Buddha, the people of Xuanhua, Inguang and Guang Chin all believe that all animals ' sperm eggs cannot be eaten. I hope we know the cause and effect and don't do anything stupid. Don't eat any food that contains eggs. South No Amitabha ~!

  "The Theory of Explicit understanding" cloud: "All eggs are not edible, have a son also".
-"Big is Tibet" 31st volume of page 882.
2018-08-22 13:35:07
http://php5.kiev.ua/manual/ru/language.namespaces.html

    Поддержать сайт на родительском проекте КГБ