开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜