Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: ' and this "

  1. #11
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Bluewalrus:
    Twey means something like:
    Code:
    <?php
    $var = "Hello";
    if($var == "Hello"){
    ?>
    You said Hello!
    <?php
    }
    ?>
    Jeremy | jfein.net

  2. #12
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Would that work for this? say $name was from a form on the previous page and was declared here.

    PHP Code:
    <?php
    $var 
    "Hello";
    if(
    $var == "Hello"){
    ?>
    You said Hello $name !
    <?php
    }
    ?>
    ----------------------------------------------------------------------
    Code:
    <?php
    $var = "Hello";
    if($var == "Hello"){
    echo "You said Hello {$name} !";
    }
    ?>

  3. #13
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No - that would not work...
    @Twey, it's .net not .org:
    http://www.smarty.net/
    Jeremy | jfein.net

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Kind of, but think of it in terms of the HTML and format accordingly, and you need to re-enter PHP parsing mode to output a variable. PHP also includes an alternative syntax for blocks to make this more readable (you get an ADA-like 'comb'):
    Code:
    <?php
      $var = 'Hello';
      $name = 'John';
    ?>
    And the output:
    Code:
    <?php if ($var === 'Hello'): ?>
      You said hello, <?php echo $name; ?>!
    <?php endif; ?>
    Ah, you're right, Nile. Thanks!

    Edit: When formatting, I like to indent PHP blocks one block above the current element, since they tend to semantically associate with the outer element:
    Code:
    <div>
      <p>
      <?php if ($var === 'Hello'): ?>
        You said hello!
      <?php else: ?>
        You didn't say hello.
      <?php endif; ?>
      </p>
    </div>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Um.. it doesn't work.
    Jeremy | jfein.net

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Only the $name bit didn't work; the idea bluewalrus was asking after (wrapping a piece of HTML in a PHP block) does. Sorry for the confusion; I've edited to make it clearer.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #17
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Ok.. sorry.
    Also, your link has a .org, instead of .net(smarty).
    Jeremy | jfein.net

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Thanks, I fixed it
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •