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! Quote 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 ?> Quote 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. Quote 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 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 Quote 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... :-/ Quote 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. Quote 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 Although, I would take a look at this comment cool! something new I learned! thank you! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.