Jump to content

[SOLVED] using variables in strings


crouzilles

Recommended Posts

Hello all,

 

I am new to PHP and to your community. I have a little programming experience in Tcl, DHTML.

 

This is the problem I am encountering:

echo("cookie is now set to: $_COOKIE['GSAdminUser']");

 

The line above comes back with this errror:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/username/gs_admin/test.php on line 18

 

If I assign the value of $_COOKIE['GSAdminUser'] to a variable and then use this variable in the echo command, all is fine and I cann see the cookie value in the page.

 

Does anybody know what I can't use the $_COOKIE['GSAdminUser'] variable directly?

 

Thank you

Link to comment
https://forums.phpfreaks.com/topic/103167-solved-using-variables-in-strings/
Share on other sites

Unfortunately, it still does not work.

 

This is my file:

<?php

setcookie("GSAdminUser", "xbourgui:1", time()+3600, "/", "127.0.0.1", 0);

?>

<html>

<head>

<link rel="styleSheet" href="css/main.css" type="text/css">

</head>

 

<body class="main">

<?php

if (isset($_COOKIE['GSAdminUSer'])) {

echo('no cookie available');

} else {

echo("cookie is now set to: {$_COOKIE['GSAdminUSer']}");

}

?>

</body>

</html>

 

All I get on screen now is this:

cookie is now set to:

 

 

 

Any ideas?

 

Thank you

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.