Jump to content

[SOLVED] functions - new


dezkit

Recommended Posts

im new to functions and i was wondering, why isnt this working?

 

<?php


function name(){
        $firstname = "Pamela";
        $lastname = "Anderson";
        echo "$firstname $lastname";
}

echo "The hottest bitch in the world is ".name();

?>


 

 

it displays, "Pamela AndersonThe hottest bitch in the world is"

Link to comment
https://forums.phpfreaks.com/topic/107558-solved-functions-new/
Share on other sites

nevermind, i figured it out, now is there a way to echo (or whatever its called) a function in an echo?

 

like:

 

 

echo "The hottest bitch in the world is name()";

<?php


function name(){
        $firstname = "Pamela";
        $lastname = "Anderson";
        return $firstname ." ". $lastname;
}

echo "The hottest bitch in the world is ". name();

?>

 

Link to comment
https://forums.phpfreaks.com/topic/107558-solved-functions-new/#findComment-551324
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.