Log in

View Full Version : {} symbols in PHP



gurmeet
12-16-2009, 06:14 AM
i am not a professional user in PHP, last week i found a script there are { } symbols in echo statement, i am unable to understand , plz tell me the meaning of these symbols, n tel me how these braces can b used...
xample is here:

echo '{'.
'succes: true,'.
'title: \'<strong>Login Success</strong>\', '.
'content: \'You have authenticated successfuly<br />'.
'click <a href="'.$successURL.'">here</a> to continue\''.
'}';
else
echo '{'.
'succes: false,'.
'title: \'<strong>Login Failed : User and Password combination is not valid</strong>\''.
'}';

djr33
12-16-2009, 06:23 AM
echo just outputs text. In this case, { and } are just text that goes into the html code as text. They are not part of PHP any more than the text in echo "hello world!"; is.

Edit: In general { and } surround sections of code, most typically within loops and if statements.
if (something) do this;
Is the same as:
if (something) { do this; }
and the {} are required if the statement takes more than one line:
if (something) {
do this;
do this;
and do this;
}

But again, the code you posted above is just text, with the html eventually displaying { and }, not some part of the PHP. The only PHP in that, really, is the echo statement, the quotation marks (' and '), and the dots connecting the strings, plus the ;s to end the lines.

gurmeet
12-16-2009, 04:32 PM
yes i think its part of AJAX coding...


i revised this code once again, its not the part of PHP... i think..