Question

Is there any other use of the question mark ? in PHP other than being part as the Ternary Operator.

Just to take note: I know about how it works in regex and all that. I am talking about the PHP language itself, not regex or what. I know how it works in opening and closing tags.

I am more concerned about tokenizing a PHP script. Is there any other token involving question mark?

I've already checked the PHP manual by the way.

Was it helpful?

Solution

Well yeah in php it is used for:

  • <?php / ?> opening tags.
  • <? ?> short opening tags.
  • <?= $variable ?> equivalent to useful when working with templates.
  • ?: ternary operator
  • And is used in preg_match() when writing regular expressions. ^\s+(\s+)?$

OTHER TIPS

For one, it is used to mark up the PHP code itself like this <? ?> :)

But seriously, are you driving at some particular use you wanted to understand?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top