本文整理汇总了PHP中Container::now方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::now方法的具体用法?PHP Container::now怎么用?PHP Container::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Container
的用法示例。
在下文中一共展示了Container::now方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: implode
echo '<div class="subtitle">2. part</div>';
$container->book = "Lord of the flies 2";
echo $container->book . '<br>';
echo $container->now . '<br>';
echo implode(' ', $container->numbers) . '<br>';
// accessing and changing providers as array
echo '<div class="subtitle">3. part</div>';
$container["book"] = "Lord of the flies 3";
echo $container["book"] . '<br>';
echo $container["now"] . '<br>';
echo implode(' ', $container["numbers"]) . '<br>';
// accessing providers as function
echo '<div class="subtitle">4. part</div>';
echo $container->book() . '<br>';
echo $container->number() . '<br>';
echo $container->now() . '<br>';
echo $container->hello("John", "Doe") . '<br>';
// singleton access
echo '<div class="subtitle">5. part</div>';
$dsn = "mysql:host=localhost;dbname=newsletter;charset=utf8";
// Host name and database name
$user = "root";
// MySQL user name
$pass = "root";
// MySQL password
$container->set("db", function ($dsn, $user, $pass) {
return new \PDO($dsn, $user, $pass);
}, true);
$db_data = array($dsn, $user, $pass);
try {
$db = $container->get("db", $db_data);
示例2: function
echo "<br>";
echo $container['book'];
// Prints "Lord of the flies 3"
echo "<br>";
echo $container['now'];
// Prints now date ("August 23, 2015, 7:28 am")
echo "<br>";
echo "---------------------------------------******************************************************************-------------------------------------------";
echo "<br>";
echo $container->book();
// Prints "Lord of the flies"
echo "<br>";
echo $container->number();
// Prints 317
echo "<br>";
echo $container->now();
// Prints now date ("August 23, 2015, 7:28 am")
echo "<br>";
echo $container->hello("John", "Doe");
// Prints "Hello John Doe"
$container->set("db", function ($dsn, $user, $pass) {
return new \PDO($dsn, $user, $pass);
}, true);
//$db = $container->get("db"); // Always returns the same instance
$container->set("MAX_BUFFER_SIZE", 200, true);
$container->set("hash", function () {
return md5(gethostname() . time());
}, true);
$value = $container->MAX_BUFFER_SIZE;
echo "<br>";
echo $value;