php - Using variable inside a function -


this seems simple issue, i'm not having luck solving , not entirely sure search. trying $logo used funciton, image uses variable defined on line 1:

$logo = 'http://dev.batman.com/logo.png';  function signup_email_body( $logo ){   $body = '<img src="'.$logo.'" />'; } 

the funciton triggered on signup , src attribute missing.

(n.b. above simplified code save masses of html)

the value of $body never returned function goes away once function call finished executing. need return value function in order use it:

$logo = 'http://dev.batman.com/logo.png';  function signup_email_body( $logo ){   return '<img src="'.$logo.'" />'; }  $body = signup_email_body( $logo ); // <-- $body has string value 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -