echo

PHP数组练习

感情迁移 提交于 2020-01-03 21:28:53
题目: 1、跳水比赛,8个评委打分,运动员的成绩是8个成绩去掉一个最高分和去掉一个最低分。剩下6个分数的平均分就是最后得分。使用一维数组实现打分功能。 2、并且把最高分和最低分的评委找出来。 解决方案: 第一个页面: <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > </head> <body> <h1>请裁判输入分数</h1> <form action="result02.php" method="post"> 裁判1<input type="text" name ="one"><br/> 裁判2<input type="text" name ="two"><br/> 裁判3<input type="text" name ="three"><br/> 裁判4<input type="text" name ="four"><br/> 裁判5<input type="text" name ="five"><br/> 裁判6<input type="text" name ="six"><br/> 裁判7<input type="text" name ="seven"><br/> 裁判8<input type="text" name ="eight"><br/> <input

Using PDO to replace mysql_connect - formatting correctly?

ぃ、小莉子 提交于 2020-01-03 10:42:08
问题 This is my current page: <?php mysql_connect('localhost', 'root', 'mypass') or die (mysql_error()); mysql_select_db('radio1') or die (mysql_error()); $result = mysql_query("SELECT *, TIME_FORMAT(airtime, '%H:%i') `airtime` from presenters"); //Table starting tag and header cells while($row = mysql_fetch_array($result)) { ?> <?php foreach($rows as $row):?> <dl class="standard"> <dt><a href="<?=$row=['link'] ?>" title="<?=$row=['presenter'] ?>"><?=$row['airtime'] . " - " .$row['presenter']?></a

How to echo variable from the class function to the other file

狂风中的少年 提交于 2020-01-03 05:05:34
问题 I am just a beginner at OOP PHP. What I want to happen is to echo the variable from the class inside the function to other file. Please take a look at this code: in class.library.php file: class db_connect { // Other functions and variables here function settings() { $sql="SELECT * FROM lms_admin_settings"; $result = $this->conn->query($sql); while($data = $result->fetch_assoc()) { $name = $data["name"]; } } } and in index.php file: include("class.library.php"); $data = new db_connect; $data-

shell脚本练习题

為{幸葍}努か 提交于 2020-01-02 23:56:16
1、编写hello world脚本 [root@proxy opt]# vim a.sh #!/bin/bash echo "hello world" 2、编写一个脚本用于创建Linux账号并设置密码,带参数形式#!/bin/bash [root@proxy opt]# vim b.sh if [ $# -lt 2 ];then echo "请输入你要创建的用户名及密码" exit 2 id $1 &> /dev/null elif [ $? -eq 0 ];then echo "用户已存在" else useradd $1 &> /dev/null echo $2 | passwd --stdin $1 &> /dev/null echo "$1用户创建成功" fi 3、判断用户是否是root管理员,是的话安装http服务 [root@proxy opt]# vim c.sh #!/bin/bash if [ root == "$USER" ];then yum -y install httpd &> /dev/null systemctl start httpd echo "httpd 下载好了" else echo "你不是root用户,无法下载httpd" exit 2 fi 4、编写一个脚本用户创建Linux账户,提示用户输入用户名和密码。要求输入密码时屏蔽输出。

如何使用Docker部署PHP开发环境

▼魔方 西西 提交于 2020-01-02 21:31:06
本文主要介绍了如何使用Docker构建PHP的开发环境,文中作者也探讨了构建基于Docker的开发环境应该使用单容器还是多容器,各有什么利弊。推荐PHP开发者阅读。希望对大家有所帮助。 环境部署一直是一个很大的问题,无论是开发环境还是生产环境,但是 Docker 将开发环境和生产环境以轻量级方式打包,提供了一致的环境。极大的提升了开发部署一致性。当然,实际情况并没有这么简单,因为生产环境和开发环境的配置是完全不同的,比如日志等的问题都需要单独配置,但是至少比以前更加简单方便了,这里以 PHP 开发作为例子讲解 Docker 如何布置开发环境。 一般来说,一个 PHP 项目会需要以下工具: Web 服务器: Nginx/Tengine Web 程序: PHP-FPM 数据库: MySQL/PostgreSQL 缓存服务: Redis/Memcache 这是最简单的架构方式,在 Docker 发展早期,Docker 被大量的滥用,比如,一个镜像内启动多服务,日志收集依旧是按照 Syslog 或者别的老方式,镜像容量非常庞大,基础镜像就能达到 80M,这和 Docker 当初提出的思想完全南辕北辙了,而 Alpine Linux 发行版作为一个轻量级 Linux 环境,就非常适合作为 Docker 基础镜像,Docker 官方也推荐使用 Alpine 而不是 Debian 作为基础镜像

PHP全栈学习笔记11

人盡茶涼 提交于 2020-01-02 20:24:14
连接MySQL mysql_connect(servername,username,password); 面向对象: <?php $servername = "localhost"; $username = "username"; $password = "password"; // 创建连接 $conn = new mysqli($servername, $username, $password); // 检测连接 if ($conn->connect_error) { die("连接失败: " . $conn->connect_error); } echo "连接成功"; ?> 面向过程: <?php $servername = "localhost"; $username = "username"; $password = "password"; // 创建连接 $conn = mysqli_connect($servername, $username, $password); // 检测连接 if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } echo "连接成功"; ?> PDO: <?php $servername = "localhost"; $username =

HTML嵌套php

杀马特。学长 韩版系。学妹 提交于 2020-01-02 18:34:21
1. <?php echo 'if you want to serve XHTML or XML documents, do it like this' ; ?> 2. <script language="php"> echo 'some editors (like FrontPage) don\'t like processing instructions' ; </script> 3. <? echo 'this is the simplest, an SGML processing instruction' ; ?> <?= expression ?> This is a shortcut for " <? echo expression ?>" 4. <% echo 'You may optionally use ASP-style tags'; %> <%= $variable; # This is a shortcut for "<% echo . . ." %> 上例中的 1 和 2 中使用的标记总是可用的,其中示例 1 中是最常用,并建议使用的。 短标记(上例 3)仅在通过 php.ini 配置文件中的指令 short_open_tag 打开后才可用,或者在 PHP 编译时加入了 --enable-short-tags 选项。 ASP 风格标记(上例 4)仅在通过

How to echo an image with php

廉价感情. 提交于 2020-01-02 09:59:29
问题 I'm trying to echo an image from my '_images' folder, but if I write the following code, it is only for my website: echo '<img src="http://mywebsite.com/mytheme/wp-content/themes/my theme/_images/project3image1.jpg">'; I've changed it to this so when someone else uses my theme, it takes them to their own website directory: echo '<img src="<?php bloginfo('stylesheet_directory'); ?>/_images/project3image1.jpg">'; But there must be something wrong with this code when I put that and preview my

Using “ echo append >> file” recursively

这一生的挚爱 提交于 2020-01-02 09:58:47
问题 I want to append a line to the end of every file in a folder. I know can use echo apendthis >> file to append the string to a single file. But what is the best way to do this recursively? 回答1: find . -type f -exec bash -c 'echo "append this" >> "{}"' \; 回答2: Literally or figuratively... Do you mean recusively to be taken literally or figuratively? If you are really in search of a specifically recursive solution, you can do that like so: operate () { for i in *; do if [ -f "$i" ]; then echo

ZH奶酪:PHP判断图片格式的7种方法

点点圈 提交于 2020-01-01 23:48:13
以图片 $imgurl = "http://www.php10086.com/wp-content/themes/inove/img/readers.gif"; 为例; 思路1. 把图片名当做字符串来处理,那么判断图片格式的也就是变成了查找“.”号的字符串。 方法一 : strrchr() 函数查找字符串在另一个字符串中最后一次出现的位置,并返回从该位置到字符串结尾的所有字符。 echo $ext = strrchr($imgurl,'.'); 输出: .gif 方法二 : strrpos() 函数查找字符串在另一个字符串中最后一次出现的位置。 注释:该函数对大小写敏感。如需进行大小写不敏感的查找,请使用 strripos() 。 过程是这样的: 先计算.号的位置,在使用substr截取字符串 echo $ext1 = substr($imgurl,strrpos($imgurl, '.')); 输出: .gif 方法三 : explode() 把字符串分割成数组,取数组最后一个键值 echo (@end(explode(".",$imgurl))); 输出: gif 思路2:把图片路径当作文件路径,那么这里就需要gd类库函数或者php文件函数 方法四 : pathinfo(path,options) 函数以数组的形式返回文件路径的信息 包括以下的数组元素:   [dirname]