1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP Error " unexpected T_STRING " , please help !

Discussion in 'PHP' started by FR3@K, Oct 7, 2007.

  1. FR3@K

    FR3@K Banned

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    wait.. one more thing.. can you teach me how to do line breaks like this:
    
    <?php 
          statement 
      statement
              statement
    ?>
    
    Code (markup):
    can anyone teach me to do that?
     
    FR3@K, Oct 7, 2007 IP
  2. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #22
    Not quite sure what you mean! what exactly are you trying to do?
     
    james_r, Oct 7, 2007 IP
  3. FR3@K

    FR3@K Banned

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    not trying to do anything..
    like chikens wrote the code in a format , line breaking..
    i want to learn where to give spaces..
    
    <?php 
      $thisPage="Home"; 
    ?>
    <html>
      <head>......</head>
      <body>
    
      <?php 
        if ($thisPage!="Home") {
          echo "<div class=\"footer\"> 
          <a href='javascript:history.go(-1)'> [ Back ]</a> 
          </div>"; 
        }
      ?>
    
      </body>
    </html>
    Code (markup):
    look at this code.. he gave spaces before writing the code..
    i want to learn this thing.
     
    FR3@K, Oct 7, 2007 IP
  4. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #24
    Oh I see.. He is just formatting the echo statement across several lines. If you don't end the statement with a ; PHP will keep reading the next line as if it were part of the same statement.
     
    james_r, Oct 7, 2007 IP
  5. FR3@K

    FR3@K Banned

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #25
    what about spaces before the coding like " echo "<div class=\"footer\"> "
     
    FR3@K, Oct 7, 2007 IP
  6. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #26
    oh, he's formatting the block of code to make it easy to read. for example:

    
    <?php
    
       for($i=0;$i<10;++$i)
       {
           if ($i == 4)
           {
               echo "here's 4!";
               $i++;
           }
           echo $i;
       }
    
    ?>
    
    PHP:
    Do you see what I mean? Indenting makes the code easy to see where the for statement and if statement start and end. When you have nested statements like that it can get complicated when your scripts are very complicated.
     
    james_r, Oct 7, 2007 IP
  7. FR3@K

    FR3@K Banned

    Messages:
    182
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #27
    yes thats what i want to learn.. the formatting...
     
    FR3@K, Oct 7, 2007 IP
  8. james_r

    james_r Peon

    Messages:
    194
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #28
    yep, that's pretty much all there is to it. just grouping the statements together inside your functions, for and while loops, and if statements
     
    james_r, Oct 7, 2007 IP