Grow your CSS skills. Land your dream job.

Php Functions

  • # February 23, 2010 at 12:30 pm

    Hi Everyone

    I need some help, Im trying to echo a function and It doesnt work, is it possible? If so how?

    eg:

    Code:
    < ?php echo "http://getUrl()"; ?>

    All it does is shows

    http://getUrl() in the address bar

    Thanks In advance

    jonleesmith

    # February 23, 2010 at 12:47 pm

    Something like this should work.

    Code:
    < ?php
    $url = getUrl();
    echo "http://".$url;
    ?>

    Basically you are trying to echo a function call within a string, which is impossible as it is treating the function call like the string.

    I’m not sure if the following also works but you could try

    Code:
    < ?php
    echo "http://".getURL();
    ?>
    # February 25, 2010 at 3:49 pm

    Does’nt seem to be working unfortunately. Gota be some how

    Code:
    $query = “SELECT title FROM go_pages “;

    $result = mysql_query($query);

    while ($row = mysql_fetch_array($result)) {
    echo “

  • $row[title]
  • “;

I want to put the getUrl() function in

Code:
# February 25, 2010 at 5:23 pm

Enclose your complex variables in curly braces and you should be fine.

Code:
echo “
  • {$row[title]}
  • “;

    # March 12, 2010 at 1:40 am

    This is the exact way to use a echo into the PHP Language,
    <?php
    $myString = "Hello!";
    echo $myString;
    echo "<h5>I love using PHP!</h5>";
    ?>

    Viewing 5 posts - 1 through 5 (of 5 total)

    You must be logged in to reply to this topic.

    *May or may not contain any actual "CSS" or "Tricks".