|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-03-26 00:17 UTC] yohgaki at dd dot iij4u dot or dot jp
Following code, needs "()" to get expected value.
$bar = true;
$str = "TEST". ($bar ? 'true' : 'false') ."TEST";
Without "(" and ")", only "true" will be in $str.
(PHP4.0.4pl1/Apache DSO/Linux, PHP4.0.5RC1/Apache DSO/W2K Server)
If this is expected behavior in PHP, it would better to be described in the Manual.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 13:00:01 2025 UTC |
I read precedence list again. There is "." operator listed and has higher precedence than "?:" operator. So PHP is working as expected. I didn't see "." It was hard to see on my browser. Thanks. Anyway, I have suggestion for the manual page, so I changed status to open as "Documentation Problem". I think the manual page better to have relevant language constructs in the precedence list even if it is not a actually a operator in PHP. (Such as "()", "{}", "::", "->", unary "-","+". It seems these are not a operator in PHP, since they are not listed. Not sure though.) Only "()" is described in the section. All of them affects how expressions are evaluated in script and I think precedence for these is important as operator precedence because programmers want expressions are evaluated as expected. How about change the section title from "Operator Precedence" to "Precedence"? Then documentation can include anything that can affects expression and still have consistency with section title. It also would be nice to have a little explaination for each operator in the precedence list. Since it is ambigous if listed operator is unary or binary. For example, unary "-" should have higher precedence than binary "-". It would be obvious for most users, but it may be usuful for someone.=== from #15368 === The operators seciot of the online PHP Manual omits mention of: {} -- used to extarct a particular character from a string (with an aside about using {} to embed variable values in strings); [] -- the array subscriptor (which is actually listed inthe operator precedence table, though mentioned nowhere else); -> -- the object property/method accessor; & -- the reference operator (also listed in the precendence table, though never explained elsewhere); => -- the array key-to-value keyword (not techniclly an operator, I know, but because it's so "punctuation-y", probably a good thing to comment on in this section). Also, the operators precendence table at http://www.php.net/manual/en/language.operators.precedence.php should probably hyperlink each operator to the appropriate page describing it. And finally, it might make more sense to put the operator precendence information (including the new and improved table with hyperlinks) right on the first page of the operators section (rather than the arithmentic operators information).