Jump to content

Recommended Posts

<!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 random

line 29 is: print " -- $undecided<br />"; // 3
and
line 38 is simply: </html>

confused?
Link to comment
https://forums.phpfreaks.com/topic/32776-solved-parse-error-unexpected-endhelp/
Share on other sites

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!!!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.