1 Star 0 Fork 0

gxxblw_com/php-example

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
join_example.php 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
黄国才 提交于 2021-07-06 23:25 +08:00 . 更新字符串操作
<?php
header('Content-type: text/html; charset=UTF-8');
$do=$_GET['do'];
if($do=='1'){
/**
* 1. 字符串输出 echo 关键词
*/
echo 'Hello gxxblw.com ';
/**
* 2、字符串输出 echo 关键词
*/
echo phpinfo();
}else if($do=='2'){
/**
* 中断php脚本执行,并输出
*/
$file_path="./readme.txt";//文件路径
$resource=fopen($file_path,"r") or die("没找不到文件");//文件不存在抛出错误提示并终止继续执行
echo '<br>'.fread($resource,filesize($file_path)); //输出文件内容
fclose($resource);//关闭流
}else if($do=='3'){
/**
* 使用"."字符串进行拼接
*/
echo '<span>'.'今天我很开心学到了php知识'.'</span><br>';
$id=1;
echo 'select uid,name form t_user where id='.$id;//输出内容select uid,name form t_user where id=1
}else if($do=='4'){
/**
* 双引号内使用变量
*/
$title='爱分享博客';
echo " 欢迎光临{$title} , gxxblw.com <br>";//输出内容:欢迎管理分享博客 , gxxblw.com
// 单引号内字符串无法使用字符串
echo '欢迎光临$title gxxblw.com <br>';//输出内容:欢迎光临$title gxxblw.com ,变量$title 原样输出
$params['a']='爱分享';
$params['b']='博客';
//双引号中使用变量建议使用话括号
echo " 欢迎光临{$params['a']}{$params['b']} , gxxblw.com <br>";//输出内容:欢迎管理分享博客 , gxxblw.com
//以下方式不推荐,某种情况会有问题
echo " 欢迎光临$params[a]$params[b] , gxxblw.com <br>";//输出内容:欢迎管理分享博客 , gxxblw.com
}else {
/**
* 多行字符串输出演示
*/
$title='爱分享博客';
echo <<<ETO
<h1>{$title}</h1>
<p>一个全栈技术分享博客</p>
<div class="body">欢迎光临爱分享博客,<a style="color: red" href="http://www.gxxblw.com">点击访问</a></div>
ETO;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gxxblw_com/php-example.git
git@gitee.com:gxxblw_com/php-example.git
gxxblw_com
php-example
php-example
master

搜索帮助