note 105559 added to language.constants

From: Date: Sat, 27 Aug 2011 14:35:45 +0000
Subject: note 105559 added to language.constants
Groups: php.notes 
Request: Send a blank email to php-notes+get-182767@lists.php.net to get a copy of this message
PHP will allow characters other than those shown for both variable names and constants, and therefore probably functin names, too. And I'm pretty sure array indexes also. Many others are allowed, while some are not. It seems like a craps-shoot at first, but there is a 'bit' of reason... you can do this: <?php $x´; // using the "acute (reverse) accent mark" (#182) ?> but not: <?php $x′; // using the "prime mark" (#8242) ?> but you can do: <?php $x‡†±√2×π // using double dagger, dagger, plus-minus, square-root, the number 2, the "times symbol" and the greek letter pi (lowercase). ?> but not: <?php $x♂♀◊∆; // using male, female, lozenge, mathematical increment symbol. ?> You can do this: <?php define('≈PI', M_PI); // 180 degrees = π radians ≈ 3.141592654 radians define('≈180°', M_PI); define('≈PI÷2', M_PI_2); // 90 degrees ≈ 1.570796327 radians define('≈90°', M_PI_2); define('≈PI÷4', M_PI_4); // 45 degrees ≈ 0.785398163 radians define('≈45°', M_PI_4); define('≈PI×3÷2', ≈PI+≈PI÷2); // 270 degrees ≈ 4.71238898 radians define('≈270°', ≈PI×3÷2); define('≈PI×2', ≈PI*2); // 360 degrees = 2π radians ≈ 6.283185307 radians define('≈360°', ≈PI×2); ?> So essentially, you must check each character for acceptance by PHP if you want to use them, but they can really add a semantical value in some cases, thus making your code easier to read and understand.. ---- Server IP: 69.147.83.197 Probable Submitter: 74.160.228.23 ---- Manual Page -- http://www.php.net/manual/en/language.constants.php Edit -- https://master.php.net/note/edit/105559 Del: integrated -- https://master.php.net/note/delete/105559/integrated Del: useless -- https://master.php.net/note/delete/105559/useless Del: bad code -- https://master.php.net/note/delete/105559/bad+code Del: spam -- https://master.php.net/note/delete/105559/spam Del: non-english -- https://master.php.net/note/delete/105559/non-english Del: in docs -- https://master.php.net/note/delete/105559/in+docs Del: other reasons-- https://master.php.net/note/delete/105559 Reject -- https://master.php.net/note/reject/105559 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182767) next »