nyzwerewolf Posted March 3, 2009 Share Posted March 3, 2009 hello all, I am extremely new to php and so far I like it. Basically, I am in a section of my book where it teaches how to change the type of a variable using settype() function. settype($variable_to_change, 'new_variable_type'); here is my code <?php $undecided = 3.14; echo "Is " .$undecided. " a double? " .is_double($undecided). "<br />" // double settype ($undecided, 'string'); echo "Is " .$undecided. " a string? " .is_string($undecided). "<br />" // string settype ($undecided, 'integer'); echo "is " .$undecided. " an integer? " .is_int($undecided). "<br />" // integer settype ($undecided, 'double'); echo "is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'bool'); echo "is " .$undecided. " a boolean? " .is_bool($undecided). "<br />"; // boolean ?> In my browser, it says the following error: Parse error: parse error, expecting `','' or `';'' in C:\wamp\www\sams\5\changing_variables.php on line 4 I followed the book.. can you please point out what exactly is wrong here? Thank you! Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/ Share on other sites More sharing options...
WolfRage Posted March 3, 2009 Share Posted March 3, 2009 You forgot to include ";" on line four and line six and eight. <?php $undecided = 3.14; echo "Is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'string'); echo "Is " .$undecided. " a string? " .is_string($undecided). "<br />"; // string settype ($undecided, 'integer'); echo "is " .$undecided. " an integer? " .is_int($undecided). "<br />"; // integer settype ($undecided, 'double'); echo "is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'bool'); echo "is " .$undecided. " a boolean? " .is_bool($undecided). "<br />"; // boolean ?> Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775262 Share on other sites More sharing options...
WolfRage Posted March 3, 2009 Share Posted March 3, 2009 Sorry for the double post, I made an error on correcting it the first time. Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775263 Share on other sites More sharing options...
Philip Posted March 3, 2009 Share Posted March 3, 2009 Quote You forgot to include ";" on line four and line six. <?php $undecided = 3.14; echo "Is " .$undecided. " a double? " .is_double($undecided). "<br />" // double settype ($undecided, 'string'); echo "Is " .$undecided. " a string? " .is_string($undecided). "<br />"; // string settype ($undecided, 'integer'); echo "is " .$undecided. " an integer? " .is_int($undecided). "<br />"; // integer settype ($undecided, 'double'); echo "is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'bool'); echo "is " .$undecided. " a boolean? " .is_bool($undecided). "<br />"; // boolean ?> and line 2 <?php $undecided = 3.14; echo "Is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'string'); echo "Is " .$undecided. " a string? " .is_string($undecided). "<br />"; // string settype ($undecided, 'integer'); echo "is " .$undecided. " an integer? " .is_int($undecided). "<br />"; // integer settype ($undecided, 'double'); echo "is " .$undecided. " a double? " .is_double($undecided). "<br />"; // double settype ($undecided, 'bool'); echo "is " .$undecided. " a boolean? " .is_bool($undecided). "<br />"; // boolean ?> Although, I would take a look at this comment Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775265 Share on other sites More sharing options...
nyzwerewolf Posted March 3, 2009 Author Share Posted March 3, 2009 oh geeeee!!!!!!!!!!!!!!!! THANK YOU!!! that was a stupid one... :-/ Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775266 Share on other sites More sharing options...
WolfRage Posted March 3, 2009 Share Posted March 3, 2009 No Problem, can you mark it solved. Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775267 Share on other sites More sharing options...
nyzwerewolf Posted March 3, 2009 Author Share Posted March 3, 2009 Quote Although, I would take a look at this comment cool! something new I learned! thank you! Link to comment https://forums.phpfreaks.com/topic/147695-solved-newbie-cant-get-settype-to-work/#findComment-775268 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.