Results 1 to 3 of 3

Thread: {} symbols in PHP

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default {} symbols in PHP

    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>\''.
    '}';

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Last edited by djr33; 12-16-2009 at 07:03 AM.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default

    yes i think its part of AJAX coding...


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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •