php基礎入門知識筆記
來源:程序員人生 發布時間:2014-06-17 08:35:35 閱讀次數:2442次
基本知識
- <?php
- echo "1 , php.ini中把display_errors=On才顯示錯誤位置<br>";
- echo "2 ,習慣使用echo和print打印<br>";
- echo "wamp安裝完后不能使用是因為安裝過iis,是apache無法啟動監聽,停止iis就可以了";
- phpinfo();
-
-
-
-
-
-
-
-
-
-
-
- #單行注釋
- ?>
簡單變量和簡單數組知識
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的保留類,并不是所有類的基類.
- <?php
- class foo {}
- $bar = new foo();
- echo $bar instanceof stdClass?'yes':'no';
-
- ?>
另外一個例子:
- <?php
-
- class CTest {
- public $property1;
- }
- $t = new CTest;
- var_dump($t instanceof stdClass);
- var_dump(is_subclass_of($t, 'stdClass'));
- echo get_class($t) . "n";
- echo get_parent_class($t) . "n";
- ?>
任何用(object)強制轉換都會得到一個stdClass的實例.
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈