You are here: syntax for two comparison operators « PHP « IT news, forums, messages
syntax for two comparison operators

Posted by Jordan Miller on 08/25/05 02:10

General question,

Is there a technical reason why PHP does not allow comparison
operator expressions like the following:

if (2 < $x <= 4) {}


I prefer this concise way as it is common for mathematics
expressions, and much easier to grasp physically on first glance.
From what I can tell, this expression can currently only be written as:

if ( $x > 2 && $x <= 4) {}


Would adding this syntax to PHP be incredibly difficult or lead to
performance slowdowns?

I think I remember reading that PHP always evaluates expressions from
right to left, so I guess there may be a considerable codebase change
required. Maybe there could be a default function workaround for this
or some other way to automagically process these more concise
expressions without too much of a slowdown?? Just curious.

Jordan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация