<?PHP//1.connect mysalTry{$a;//NULL$b = Is_int (2);//BOOL$c =2;//int$d =2.5;//float$str="ABC";//string;$arr =Array ("username"="User1", "pwd"=123456 ); //Array ();$pdo =NewPDO ("Mysql:host=localhost;dbname=studemo","Root","");//Object$file = fopen ("./data.txt","w+");//Resource$dsn="Mysql:host=localhost;dbname=studemo"; $name="Root"; $pwd=""; $pdo=NewPDO ($dsn, $name, $pwd);//Object$pdoSetAttribute (Pdo::attr_errmode, pdo::errmode_exception);//BOOL}Catch(Pdoexception $e) {//$e is just a variable that can be changed to $ A, $b$e-getMessage ();}//2.write SQL$sql="SELECT * from user";//string//3.execute SQL$stmt = Query ($sql), $pdo//Object Gets object (Pdostatement Class) through the query ($sql) method, $pdo$row = $stmt-RowCount ();//int$res = Fetch (PDO::FETCH_ASSOC) $stmt;//array $res, result is an array ();
Examples of eight data types in PHP