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
Post a Comment