PHP Return in function Fedex
Dont know if I should add to this post or no开发者_JAVA技巧t but it is kind of relevant I think
This works just fine
function getProperty($var)
{
if($var == 'check')
Return true;
if($var == 'shipaccount')
Return '286096425543324';
But this does not? How would one enter a
$fedex_account = "286096425543324";
function getProperty($var)
{
if($var == 'check')
Return true;
if($var == 'shipaccount')
Return '$fedex_account';
'$fedex_account'
Single quotes don't expand variables. Just do this:
function getProperty($var){
// You need this if $fedex_account is a global variable
global $fedex_account;
if($var == 'check') Return true;
if($var == 'shipaccount') Return $fedex_account;
Read about Visibility - $fedex_account
are in other scope.
and about quotes.
精彩评论