PHP echo function return value vs echo inside function

后端 未结 5 1977
一向
一向 2020-12-16 04:06

Typically, I\'ll write a function like so:

function alertClass($field,$full=false){
 global $formErrors;
 $html = $full ? \' class=\"alert\"\' : \' alert\';
         


        
5条回答
  •  伪装坚强ぢ
    2020-12-16 04:35

    for example when you echo the text out of your function just like this...

    function yourStatus(){
       echo ' Done';
    }
    
    echo 'Status ='. yourStatus();
    

    your output will look like this

    "DoneStatus ="
    

    instead of

    "Status = Done"
    

    cheers

提交回复
热议问题