SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: Php echos

  1. #1
    ********* MONSTER gamerpress's Avatar
    Join Date
    Dec 2004
    Location
    NY
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Php echos

    Note: Im the biggest php noob ever!

    Right, want i want to do is transform this:

    <?php echo "$site_url"; ?>

    Into

    {site_url}

    how would i go about doing it?

    If it helps in anyway:

    $site_url = 'http://website.com';

  2. #2
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Brisbane, Australia
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, if you had this code:
    <?php
    $site_url = 'http://website.com';
    echo '{'.$site_url.'}';
    ?>

    It would output:
    {http://website.com}

    Is that what you're looking for?

  3. #3
    ********* MONSTER gamerpress's Avatar
    Join Date
    Dec 2004
    Location
    NY
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No no, i want: {site_url} to output http://website.com

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Brisbane, Australia
    Posts
    35
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to hang around and wait for someone else to weigh in on this, because I could be wrong... but I don't think this is possible.

    Not without creating a heap of other hoops to jump through, anyway.

    You see, PHP is programming code - you have commands that do stuff. If you want to echo something out, you need to run the ECHO command. {} has a very different meaning with PHP.

  5. #5
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am confused, do you want URL to output like {url} or visa versa?

    To do the method above, you would need to read the "<a href=''></a>" tag and pull the URL from it.

    Otherwise you just have PHP strip the '{'s and echo it in the form of a url link.

    One way is much easier than the other.
    ]

  6. #6
    SitePoint Member
    Join Date
    May 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok i'm taking a guess at what you are looking for (having a little more information wouldn't hurt here)

    PHP Code:
    $site_url 'www.domain.com';
    $body "Welcome to {site_url}. Enjoy your stay";

    $formatted_body str_replace('{site_url}'$site_url$body);

    echo 
    $formatted_body

  7. #7
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dannyf
    Ok i'm taking a guess at what you are looking for (having a little more information wouldn't hurt here)

    PHP Code:
    $site_url 'www.domain.com';
    $body "Welcome to {site_url}. Enjoy your stay";

    $formatted_body str_replace('{site_url}'$site_url$body);

    echo 
    $formatted_body
    Good one!!!

  8. #8
    Working on it... Contrid's Avatar
    Join Date
    Apr 2006
    Location
    Online
    Posts
    955
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gamerpress
    No no, i want: {site_url} to output http://website.com
    You have your answer there from 'Dannyf'

    If you wanted the variable itself to be {site_url}...that isn't possible.(as far as I know).

    Good luck.

  9. #9
    Evil Genius MilchstrabeStern's Avatar
    Join Date
    Nov 2003
    Location
    Arizona
    Posts
    1,131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see now, your question was a little confusing, sorry.
    ]


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
  •