鍍金池/ 問答/Java  PHP/ 要怎麼把寫在裡面的值提到外面用?

要怎麼把寫在裡面的值提到外面用?

假設(shè)我在一些if裡面產(chǎn)生了一個(gè)值

把 $name 提到這裡來用

if(xxx==xxx){
    if(xxx==xxx){
        if(xxx==xxx){
            $name = xxx;
        }
    }
}

或這裡

我想把 $name 提到 if 外面來用
這樣我該怎麼做呢?!

回答
編輯回答
凝雅

$name設(shè)為全局變量不就可以了么

2017年9月11日 00:37
編輯回答
青裙

不太明白什么意思但應(yīng)該可以這樣寫:

<?php
function test() {
    global $teee;
    $teee = 1;
}
test();
echo $teee;
2018年1月27日 09:12
編輯回答
凹凸曼
var $name;
if(xxx==xxx){
  if(xxx==xxx){
      if(xxx==xxx){
          $name = xxx;
      }
  }
}
2017年4月14日 13:28