Concatenating ECHO syntax in PHP

后端 未结 5 1148
南笙
南笙 2020-12-30 06:35

I have made a small function (WordPress), using echo .

/* .. Some code */
switch ($linktype) {
    case \"next\":
        echo \'

5条回答
  •  醉话见心
    2020-12-30 07:03

    As a future memo to me:

    $squarer = function ($x) { $out = $x*$x; echo "done!\n"; return $out; };
    
    echo 'The square of 2 is ' . $squarer(2) . "!\n";
    echo 'The square of 2 is ', $squarer(2), "!\n";
    
    // **** OUTPUT ****
    // done!
    // The square of 2 is 4!
    // The square of 2 is done!
    // 4!
    

提交回复
热议问题