note 103594 added to language.types.type-juggling

From: Date: Thu, 21 Apr 2011 17:53:02 +0000
Subject: note 103594 added to language.types.type-juggling
Groups: php.notes 
Request: Send a blank email to php-notes+get-179055@lists.php.net to get a copy of this message
Type casting from string to int and vice versa is probably the most common conversation. PHP does this very simply through the +. and .= operators, removing any explicit casting: <?php $x = 1; var_dump($x); // int(1) $x .= 1; var_dump($x); // string(2) "11"; also an empty string ("") would cast to string without changing $x $x = "1"; var_dump($x); // string(1) "1" $x += 1; var_dump($x); // int(2); also a zero value (0) would cast to int without changing $x ?> ---- Server IP: 69.147.83.197 Probable Submitter: 128.192.32.117 ---- Manual Page -- http://www.php.net/manual/en/language.types.type-juggling.php Edit -- https://master.php.net/note/edit/103594 Del: integrated -- https://master.php.net/note/delete/103594/integrated Del: useless -- https://master.php.net/note/delete/103594/useless Del: bad code -- https://master.php.net/note/delete/103594/bad+code Del: spam -- https://master.php.net/note/delete/103594/spam Del: non-english -- https://master.php.net/note/delete/103594/non-english Del: in docs -- https://master.php.net/note/delete/103594/in+docs Del: other reasons-- https://master.php.net/note/delete/103594 Reject -- https://master.php.net/note/reject/103594 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179055) next »