[php学習二]基本文法練習二

3397 ワード


    
    Second Php

29,"C "=>31,"  "=>26);
function NormalarrToStr($arr){
    $r = "";
    for ($x = 0; $x < count($arr); $x ++){
        $r = $r . " " . $arr[$x];// .         ~!
    }
    return $r;
}
function KeyValueArrToStr($arr){
    $r = "";
    foreach($arr as $x => $xValue){
        $r = $r . " " . "[$xValue]$x";
    }
    return $r;
}
echo "   :",NormalarrToStr($names),"
"; sort($names); echo " :",NormalarrToStr($names),"
"; echo " :",KeyValueArrToStr($nameAndage),"
"; ksort($nameAndage); echo " :",KeyValueArrToStr($nameAndage),"
"; /* * 1,$GLOBALS 。 ; * 2,$GLOBALS . .http://www.runoob.com/php/php-superglobals.html * 3,$_REQUEST HTML , Input . 2 ; * */ $x = 25;$y=75; function TestGlobals(){ global $x; $GLOBALS['z'] = $x + $GLOBALS['ya']; } TestGlobals(); echo $z,'
'; echo $_SERVER["PHP_SELF"],'
'; echo $_SERVER["SERVER_NAME"],'
'; echo $_SERVER["HTTP_HOST"],"
"; echo $_SERVER["SERVER_ADDR"],"
"; echo $_SERVER["REQUEST_METHOD"],"
"; echo $_SERVER["REMOTE_ADDR"],"
"; echo $_SERVER["SCRIPT_FILENAME"],"
"; ?>
">

Name:

"; ?> ?Param 1=パラメータ1&Param 2=パラメータ2">テストGET "; ?> "; } $x = 1; TestVar($x); echo $x . "
";// 2,& ; echo "__Line__:",__LINE__,"__File__:",__FILE__,"
"; echo "__Dir__:",__DIR_,"
"; class TestGlobalVar{ function MyFun1(){ echo "__FUNCTION__",__FUNCTION__, ";__Class__:",__CLASS__,"
"; } } $V1 = new TestGlobalVar(); $V1->MyFun1(); class MyBase{ function SayHello(){ echo "Hello"; } } //trait , .~ trait TraitSay{ public function SayHello(){ parent::SayHello(); echo "World"; } } class MyChild extends MyBase{ use TraitSay; } $c = new MyChild(); $c->SayHello(); ?>
基本文法の差は多くありません.