static::staticFunctionName()

I know what self::staticFunctionName() and parent::staticFunctionName() are, and how they are different from each other and from $this->functionName . But what is static::staticFunctionName() ? It's the keyword used in PHP 5.3+ to invoke late static bindings. Read all about it in the manual: http://php.net/manual/en/language.oop5.late-static-bindings.php In summary, static::foo() w

静:: staticFunctionName()

我知道self::staticFunctionName()和parent::staticFunctionName()是什么,它们是如何从$this->functionName彼此不同的。 但什么是static::staticFunctionName() ? 这是PHP 5.3+中用于调用晚期静态绑定的关键字。 阅读手册中的所有内容:http://php.net/manual/en/language.oop5.late-static-bindings.php 总之, static::foo()工作方式类似于动态self::foo() 。 class A { static function foo() { //

What exactly are late static bindings in PHP?

PHP中迟到的静态绑定究竟是什么? As of PHP 5.3.0, PHP implements a feature called late static binding which can be used to reference the called class in the context of static inheritance. Late static binding tries to solve that limitation by introducing a keyword that references the class that was initially called at runtime. It was decided not to introduce a new keyword, but rather use static

PHP中迟到的静态绑定究竟是什么?

PHP中迟到的静态绑定究竟是什么? 从PHP 5.3.0开始,PHP实现了一个叫做后期静态绑定的特性,它可以用来在静态继承的上下文中引用被调用的类。 晚期静态绑定试图通过引入引用最初在运行时调用的类的关键字来解决该限制。 决定不引入新的关键字,而是使用已经保留的static 。 我们来看一个例子: <?php class Car { public static function run() { return static::getName();

What's the difference between :: (double colon) and

There are two distinct ways to access methods in PHP, but what's the difference? $response->setParameter('foo', 'bar'); and sfConfig::set('foo', 'bar'); I'm assuming -> (dash with greater than sign or chevron) is used for functions for variables, and :: (double colons) is used for functions for classes. Correct? Is the => assignment operator only used to assign data within

::(双冒号)和。之间的区别是什么?

在PHP中访问方法有两种不同的方式,但有什么不同? $response->setParameter('foo', 'bar'); 和 sfConfig::set('foo', 'bar'); 我假设-> (破折号大于符号或V形)用于变量的函数,并且:: :(双冒号)用于类的函数。 正确? =>赋值运算符仅用于在数组内分配数据吗? 这是在对比的是=被用于实例化或修改变量赋值运算符? 当左边部分是对象实例时,可以使用-> 。 否则,您使用:: 。 这意味着->主要用于

What's the meaning of the PHP token name T

This question already has an answer here: PHP expects T_PAAMAYIM_NEKUDOTAYIM? 7 answers From the PHP docs: Paamayim Nekudotayim would, at first, seem like a strange choice for naming a double-colon. However, while writing the Zend Engine 0.5 (which powers PHP 3), that's what the Zend team decided to call it. It actually does mean double-colon - in Hebrew! 这是范围解析运算符。

PHP标记名称T的含义是什么?

这个问题在这里已经有了答案: PHP期望T_PAAMAYIM_NEKUDOTAYIM? 7个答案 从PHP文档: 起初,Paamayim Nekudotayim似乎是命名双冒号的奇怪选择。 但是,在编写Zend Engine 0.5(支持PHP 3)时,Zend团队决定称之为Zend Engine 0.5。 它实际上意味着双冒号 - 希伯来语! 这是范围解析运算符。

What do two colons mean in PHP?

I don't know what it's doing when we have this situation: Foo::Bar It looks like a path. That's (generally) for accessing a static method or property in a class. It's called the scope resolution operator, or Paamayim Nekudotayim (which leads to some amazingly confusing error messages!). See http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php. The :: operato

PHP中的两个冒号意味着什么?

当我们遇到这种情况时,我不知道它在做什么: Foo::Bar 它看起来像一条路。 这(通常)用于访问类中的静态方法或属性。 它被称为范围解析运算符,或Paamayim Nekudotayim(导致一些令人惊讶的混淆错误消息!)。 见http://www.php.net/manual/en/language.oop5.paamayim-nekudotayim.php。 ::运算符是范围解析运算符。 它用于从类外部访问类常量或静态属性和方法: ClassName::CONSTANT_VALUE ClassName::staticMethod(

What does ":" mean in PHP?

Possible Duplicate: What is “:” in PHP? What does the : mean in the following PHP code? <?php while (have_posts()) : the_post(); ?> It's called an Alternative Syntax For Control Structures. You should have an endwhile; somewhere after that. Basically, it allows you to omit braces {} from a while to make it look "prettier"... As far as your edit, it's called th

“:”在PHP中意味着什么?

可能重复:什么是PHP中的“:”? 什么是:在下面的PHP代码是什么意思? <?php while (have_posts()) : the_post(); ?> 它被称为控制结构的替代语法。 你应该有一个endwhile; 之后的某个地方。 基本上,它可以让你省略大括号{} ,使它看起来更“漂亮”...... 就编辑而言,它被称为三元运算符(这是第三部分)。 基本上这是一个赋值速记。 $foo = $first ? $second : $third; 就像说一样(只是更短): if ($fir

What is ":" in PHP?

符号是什么意思:在PHP中是什么意思? PHP offers an alternative syntax for some of its control structures; namely, if, while, for, foreach, and switch. In each case, the basic form of the alternate syntax is to change the opening brace to a colon (:) and the closing brace to endif;, endwhile;, endfor;, endforeach;, or endswitch;, respectively. You also encounter : if you use the alternative synt

什么是PHP中的“:”?

符号是什么意思:在PHP中是什么意思? PHP为其控制结构提供了一种替代语法; 即if,while,for,foreach和switch。 在每种情况下,替代语法的基本形式是分别将大括号分别更改为冒号(:)和结束大括号,以分别结束endif,endwhile,endfor ;, endforeach ;,或endswitch。 您还遇到:如果您对控制结构使用替代语法: <?php if ($a == 5): echo "a equals 5"; echo "..."; elseif ($a == 6): echo "a equals 6";

C#'s null coalescing operator (??) in PHP

Is there a ternary operator or the like in PHP that acts like ?? of C#? ?? in C# is clean and shorter, but in PHP you have to do something like: // This is absolutely okay except that $_REQUEST['test'] is kind of redundant. echo isset($_REQUEST['test'])? $_REQUEST['test'] : 'hi'; // This is perfect! Shorter and cleaner, but only in this situation. echo null? : 'replacement if empty'; // Thi

PHP中C#的空合并运算符(??)

在PHP中有三元操作符或类似操作?? 的C#? ?? 在C#中是干净和短的,但在PHP中,你必须做一些事情: // This is absolutely okay except that $_REQUEST['test'] is kind of redundant. echo isset($_REQUEST['test'])? $_REQUEST['test'] : 'hi'; // This is perfect! Shorter and cleaner, but only in this situation. echo null? : 'replacement if empty'; // This line gives error when $_REQUEST['test'] is NOT se

Using PHP 5.3 ?: operator

With this test page: $page = (int) $_GET['page'] ?: '1'; echo $page; I don't understand the output I'm getting when page is undefined: Request Result ?page=2 2 ?page=3 3 ?page= 1 ? error: Undefined index page Why the error message? It's PHP 5.3; why doesn't it echo "1"? The proper way (in my opinion) would be: $page = isset($_GET['page']) ? (i

使用PHP 5.3?:运算符

有了这个测试页面: $page = (int) $_GET['page'] ?: '1'; echo $page; 我不明白当页面未定义时我得到的输出: Request Result ?page=2 2 ?page=3 3 ?page= 1 ? error: Undefined index page 为什么错误信息? 它是PHP 5.3; 为什么不回显“1”? 正确的方式(在我看来)是: $page = isset($_GET['page']) ? (int) $_GET['page'] : 1; 即使你使用了新的风格,你也会遇到?page=0 (因为0评估为false)

?: operator (the 'Elvis operator') in PHP

I saw this today in some PHP code: $items = $items ?: $this->_handle->result('next', $this->_result, $this); I'm not familiar with the ?: operator being used here. It looks like a ternary operator, but the expression to evaluate to if the predicate is true has been omitted. What does it mean? It evaluates to the left operand if the left operand is truthy, and the right operand

?:运营商('Elvis运营商')使用PHP

我今天在一些PHP代码中看到了这一点: $items = $items ?: $this->_handle->result('next', $this->_result, $this); 我不熟悉在这里使用的?:操作符。 它看起来像一个三元运算符,但是要评估谓词是否为真的表达式已被省略。 这是什么意思? 如果左操作数是truthy,则它评估左操作数,否则评估右操作数。 在伪代码中, foo = bar ?: baz; 大致解决 foo = bar ? bar : baz; 要么 if (bar) { foo = bar; }