linux - php - 快速入门 hello world页面 , 启动服务器:php -S localhost:3000 链接mysql mysqli
访问量: 378
refer to:
https://www.php.net/manual/en/tutorial.firstpage.php
(注意:启动php server , 也可以直接 php -S localhost:3000)
注意2:
如果发现错误: Uncaught Error: Class "mysqli" not found in
就参考这个: https://stackoverflow.com/a/61409413/445908
docker-php-ext-install mysqli
原文:
apache + php的安装方式的默认 解析目录:
/var/www/html
创建一个新的页面:
hi.php
<html> <body> <?php echo '<p>hihihi</p>'; ?> <?php echo '<p>hihihi2</p>'; ?> <?php echo '<p style="color: red">hihihi3</p>'; ?> <?php echo '<p style="font-size: 30px">hihihi4</p>'; ?> <?php echo '<p>hihihi5</p>'; ?> <h3>================= </h3> <?php phpinfo(); ?> <h3>=== print one var </h3> <?php echo $_SERVER['HTTP_USER_AGENT']; ?> <h3> if, function example </h3> <?php if(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE){ echo 'You are using IE '; }else{ echo "You are not using IE, you are using firefox, chrome ... "; } ?> <h3> example 4</h3> <?php if(TRUE){ ?> <p>hihihi, I am true </p> <?php } else { ?> <p> i am false, you will never see me </p> <?php } ?> </body> </html>
这样就可以看到输出了:
操作表单:
<form action="action.php" method="post"> <p>Your name: <input type="text" name="name" /></p> <p>Your age: <input type="text" name="age" /></p> <p><input type="submit" /></p> </form>
action.php
<body> Hi , <br/> name is: <?php echo htmlspecialchars($_POST['name']) ?> <br/> age is: <?php echo (int)$_POST['age']; ?> <br/> </body>