php基礎入門知識筆記

來源:互聯網
上載者:User

基本知識

<?php教程
echo "1 , php.ini中把display_errors=On才顯示錯誤位置<br>";
echo "2 ,習慣使用echo和print列印<br>";
echo "wamp安裝完後不能使用是因為安裝過iis,是apache無法啟動監聽,停止iis就可以了";
phpinfo();//每行語句使用分號";"結束

/*
php.ini中把display_errors=On才顯示錯誤位置
習慣使用echo和print列印
*/

/*
多行注釋
*/

//單行注釋
#單行注釋
?>

簡單變數和簡單數組知識
1 ,htm和php混編
2, 一個語句以 ";" (分號結束)
3,如何定義一個變數,和變數使用

php資料運算類型
四種標量變數
boolean
integer
float,double
string
兩種複合類型
array
object

<?php
echo "<br>";
echo "如何定義一個變數,和變數使用<br>";

$a=9;
echo "$a";
echo "<br>";
$b1=true;$b2=FALSE;
$f=1.26;
$s="字串類型";
echo "int".$a."boolean".$b1."float".$f."string".$s ;

$arr=array(1,2,3,4,5);
$arr2=array("id"=>100,"title"=>"this is new" );
$arr3=array(array(1,2,3,4),array(5,6));
echo "<br>";
echo $arr;
print_r( $arr2);
echo "<br>";
echo $arr3[0][3].$arr3[1][1];
echo $arr2['id'];

?>


stdClass類是PHP的一個內部保留類,初始時沒有成員變數也沒成員方法,所有的魔術方法都被設定為NULL,可以使用其傳遞變數參數,但是沒有可以調用的方法。stdClass類可以被繼承,只是這樣做沒有什麼意義。

該類是PHP的保留類,並不是所有類的基類。

view sourceprint?1 <?php 

2 class foo {} 

3 $bar = new foo(); 

4 echo $bar instanceof stdClass?'yes':'no'; 

5 //output:no

另外一個例子:

view sourceprint?01 <?php 

02 // CTest does not derive from stdClass 

03 class CTest { 

04     public $property1; 

05 } 

06 $t = new CTest; 

07 var_dump($t instanceof stdClass);            // false 

08 var_dump(is_subclass_of($t, 'stdClass'));    // false 

09 echo get_class($t) . "n";                   // 'CTest' 

10 echo get_parent_class($t) . "n";            // false (no parent) 

11 ?>

任何用(object)強制轉換都會得到一個stdClass的執行個體。

參考:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.