Brunner41 Posted January 4, 2007 Share Posted January 4, 2007 <!DOCTYPE html PUBLIC\"-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html> <head> <title>Listing 4.2 Changing the Type of a Variable with settype()</title> </head> <body> <div> <?php $undecided = 3.14; print gettype( $undecided ); // double print " -- $undecided<br />"; // 3.14' settype( $undecided, string ); print gettype( $undecided ); // string print " -- $undecided<br />"; // 3.14 settype( $undecided, int ); print gettype( $undecided ); // integer print " -- $undecided<br />"; // 3 settype( $undecided, double ); print gettype( $undecided ); // double print " -- $undecided<br />"; // 3.0 settype( $undecided, bool ); print gettype( $undecided ); // boolean print " -- $undecided<br />"; // 1 ?> </div> </body></html>----------------------------------------------------------------------------------------------------------------------------------that's my code and the error which is: parse error, unexpected $end etc etc claims to be on line 29, line 38 and some others...it appears to be kind of randomline 29 is: print " -- $undecided<br />"; // 3andline 38 is simply: </html>confused? Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/ Share on other sites More sharing options...
Jessica Posted January 4, 2007 Share Posted January 4, 2007 What's with this apostrophe?"; // 3.14' settype( $undecided, string ); Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/#findComment-152591 Share on other sites More sharing options...
Brunner41 Posted January 4, 2007 Author Share Posted January 4, 2007 i don't know, i'm not 100% sure where it came from :P, but it doesn't affect anything if i take it away. Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/#findComment-152596 Share on other sites More sharing options...
Jessica Posted January 4, 2007 Share Posted January 4, 2007 Edit:bool settype ( mixed &var, string type )The type must be a string."string" not string"int" not inthttp://us3.php.net/settypeLook at the example. Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/#findComment-152598 Share on other sites More sharing options...
Brunner41 Posted January 4, 2007 Author Share Posted January 4, 2007 Thankyou!I can see how this came about. The script is actually from a book I'm working with. I think it may either be too old or have a few errors in it itself. They had the settype( $undecided, int ); without the double quote marks....and it actually came up with error saying "expected 'int' " so i added in some single quote marks which seemed to cause the errors I have now. I took the single quote marks away again and the parse error remained. Now I know it's double quotes in settype, not single quotes or none at all. Thanks a lot!!! Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/#findComment-152602 Share on other sites More sharing options...
Jessica Posted January 4, 2007 Share Posted January 4, 2007 No problem. Don't use books...books suck. Use the manual ;) Quote Link to comment https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/#findComment-152604 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.