- 下载php
- 配置httpd
LoadModule php7_module D:/wamp/php/php7apache2_4.dll Include conf/extra/httpd-fcgid.conf PHPIniDir "D:/wamp/php/" <IfModule dir_module> DirectoryIndex index.php index.html default.html index.hml </IfModule> <IfModule mime_module> AddType application/x-httpd-php .php </IfModule> <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch>
- php.ini
extension_dir = "D:/wamp/php/ext" extension=php_mbstring.dll extension=php_mysqli.dll extension=php_pdo_mysql.dll short_open_tag = On date.timezone=PRC
- 测试
<?php // phpinfo(); $link=mysqli_connect('localhost:3306','root','cruces') or die('error'); var_dump($link); ?>1
<?php $link=mysqli_connect('localhost','root','cruces','abate'); $sql='select * from `student`'; $result=mysqli_query($link,$sql); $data=mysqli_fetch_all($result,MYSQLI_ASSOC); // var_dump($data); echo json_encode($data); ?>
<?php $arr=['aa'=>'aaa','bb'=>'bbb']; // print_r($arr); $jsonStr=json_encode($arr); echo '<br/>'; echo $jsonStr; $string=json_decode($jsonStr); echo '<br/>'; print_r($string); ?>