HP3-SiS2什么意思

$students = array(
'2010'=&array('令狐冲',&59&),
'2011'=&array('林平之',&44&),
'2012'=&array('曲洋',&89&),
'2013'=&array('任盈盈',&92&),
'2014'=&array('向问天',&93&),
'2015'=&array('任我行',&87&),
'2016'=&array('冲虚',&58&),
'2017'=&array('方正',&74&),
'2018'=&array('岳不群',&91&),
'2019'=&array('宁中则',&90&),
);//10个学生的学号、姓名、分数,用数组存储
foreach($students as $key=&$val)
{ //使用循环结构遍历数组,获取学号
echo $ //输出学号
//循环输出姓名和分数
foreach($val as $v)
echo &&br /&&;
$totalMoney = 0;//总工资
$basicMoney =
300;//基本工资
$sex = &男&;
$noHouse = TRUE; //是否有房
$houseMoney =
150;//住房补贴
$isPregnancy = TRUE; //是否怀孕
$pregnancyMoney =
100;//怀孕补贴
if($sex==&男&)
$totalMoney = $basicMoney
+ 0;// 男的没奖金
if($noHouse)
$totalMoney = $totalMoney
else if($sex==&女&)
$totalMoney = $basicMoney
+ 300;// 女的有奖金300元
if($isPregnancy)
$totalMoney = $totalMoney
+ $pregnancyM
echo $totalM
$students = array(
'2010'=&'令狐冲',
'2011'=&'林平之',
'2012'=&'曲洋',
'2013'=&'任盈盈',
'2014'=&'向问天',
'2015'=&'任我行',
'2016'=&'冲虚',
'2017'=&'方正',
'2018'=&'岳不群',
'2019'=&'宁中则',
);//10个学生的学号和姓名,用数组存储
//使用循环结构遍历数组,获取学号和姓名
foreach($students as $key=&$v)
echo $key.&:&.$v;//输出(打印)学号:姓名
echo &&br /&&;
$students = array(
);//10个学生的学号和姓名,用数组存储
//使用循环结构遍历数组,获取学号和姓名
foreach($students as $v)
echo $v;//输出(打印)姓名
echo &&br /&&;
//for语句写法
for($i=1,$sum=0;$i&=100;$i++)
$sum = $sum + $i; // 累加求和
echo &for语句的运行结果:&.$sum.&&br /&& ;
//while语句写法
1 ; // 从1开始累加
$sum = 0; //初始化和为0
while($i&=100){
//判断是否小于100
$sum = $sum + $i; // 累加求和
$i++; //递增1
echo &while语句的运行结果:&.$sum.&&br /&& ;
1 ; //从第1圈开始跑
echo &在跑第&.$i.&圈。&;
}while($i&=10)
$sum = 12;//小宠物当前的饥饿程度
echo &我饿啦:-(&;
echo &&br /&&;
while($sum&100)
{//小宠物的饥饿程度到100,表示小宠物吃饱啦,不用继续喂了,没吃饱继续喂食
$num = rand(1,20);//随机数,模拟喂食小宠物的小面包
$sum = $sum + $ //小宠物吃小面包
echo &我还没吃饱呢!&;
echo &&br /&&;
echo &终于吃饱啦^_^&;
$num = rand(1,50);//获取1至50的随机数
$info = &&;//提示信息
switch($num){
$info = &恭喜你!中了一等奖!&;
$info = &恭喜你!中了二等奖!&;
$info = &恭喜你!中了三等奖!&;
$info = &很遗憾!你没有中奖!&;
echo $ //输出是否中奖
$totalMoney = 0;//总工资
$basicMoney =
2000;//基本工资
$sex = &男&;
if($sex==&男&){
$totalMoney = $basicMoney
+ 0;// 男的没奖金
}else if($sex==&女&){
$totalMoney = $basicMoney
+ 300;// 女的有奖金300元
echo $totalM
$shoesPrice = 49; //鞋子单价
$shoesNum = 1; //鞋子数量
$shoesMoney= $shoesPrice *$shoesN
$shirtPrice = 99; //衬衣单价
$shirtNum = 2; //衬衣数量
$shirtMoney=$shirtPrice *$shirtN
$orderMoney= $shoesMoney+$shirtM
echo $orderM
$maxLine = 4; //每排人数
$no = 17;//学生编号
$line=ceil($no/$maxLine);
$row=$no%$maxLine?$no%$maxLine:$maxL
echo &编号&b&&.$no.&&/b&的座位在第&b&&.$line.&&/b&排第&b&&.$row.&&/b&个位置&;
$conn=@mysql_connect(&localhost&,&username&,&password&);
echo &出错了,错误原因是:&.$php_
$a = &张先生&;
$tip=$a.&,欢迎你在慕课网学习php!&;
$b = &东边日出西边雨&;
$b.=&,道是无情却有情&;
$c = &东边日出西边雨&;
$c=$c.&,道是无情却有情&;
$tip.&&br /&&;
$b.&&br /&&;
$c.&&br /&&;
$a = 78;//成绩
$b= $a&=60?&及格&:&不及格&;
$a = &我在慕课网学习PHP!&;
$a = &我天天在慕课网学习PHP!&;
echo $b.&&br /&&;
echo $c.&&br /&&;
$english = 110; //英语成绩
$math= 118; //数学成绩
$biological = 80; //生物成绩
$physical = 90; //物理成绩
$sum=$english+$math+$biological+$
$avg=$sum/4;
$x=$math-$
$x2=$english*$
echo &总分:&.$sum.&&br /&&;
echo &平均分:&.$avg.&&br /&&;
echo &数学比英语高的分数:&.$x.&&br /&&;
echo &英语成绩的平方:&.$x2.&&br /&&;
define(&PI1&,3.14);
$p = &PI1&;
$is1=defined($p);
$is2=defined(&PI2&);
var_dump($is1);
var_dump($is2);
//定义圆周率的两种取值
define(&PI1&,3.14);
define(&PI2&,3.142);
//定义值的精度
$height = &中&;
//根据精度返回常量名,将常量变成了一个可变的常量
if($height == &中&){
$p = &PI1&;
}else if($height == &低&){
$p = &PI2&;
$area=constant($p)*$r*$r;
define(&PI&,3.14);
echo &面积为:&.(PI*$r*$r).&&br /&&;
echo &周长为:&.(2*PI*$r).&&br /&&;
Copyright (C)
All Rights Reserved | 京ICP备 号-2php命令行用法简介 - Just Code - ITeye技术网站
博客分类:
Php是一个非常流行的web服务端脚本语言。其实,php不仅仅可以在web服务器中充当重要角色。在命令行一样可以执行。
本文中,笔者为各位介绍下php在命令行中的使用方法。
查看php的版本、配置
在命令行中输入php –v 即可查看当前php的版本。
PHP 5.2.17(cli) (built: Feb
Copyright (c)
The PHP Group
Zend Engine v2.2.0, Copyright (c)
Zend Technologies
with Zend Optimizer v3.3.9, Copyright (c) , by Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c)
eAccelerator, by eAccelerator
其他的选项有: –m、-i。笔者在这里就不给出列子了。
-m 会显示当前php加载的有效模块。
-i 则输出无html格式的phpinfo。
使用 –ini 选项可以输出当前php加载ini配置文件的数量、路径信息。
在命令行中运行php程序
从命令行运行php非常简单。但有些注意事项需要各位了解下。诸如$_SESSION之类的服务器变量是无法在命令行中使用的,其他代码的运行则和web服务器中完全一样^_^。
echo “运行php命令行echo”;
把上面的代码另存为hello.php 。在命令行中敲入 php –f hello.php。显示结果如下:
在命令行中执行php文件的好处之一就是可以通过脚本实现一些计划任务的执行。而毋须通过web服务器^_^。
当然,我们也可以直接在php中调试代码:输入php –r 指令,会出现一个”&”符号。这表示已经进入到php的shell中,可以直接写代码,并执行。
-bash-3.2$ php -r '
& for($i=0;$i&2;$i++){
& echo "Number: {$i}\n";
还可以使用php –a 命令打开交互模式,输入一行代码,php会实时输出结果。
检测php语法、高亮输出
不用执行代码,我们可以在命令行下检测php文件的语法错误。
-bash-3.2$ php -l hello.php
No syntax errors detected in hello.php
程序员经常会需要将php代码高亮原样输出,使用php –s 即可
-bash-3.2$ php -s hello.php
&code&&span style="color: #000000"&
&span style="color: #0000BB"&&?php&br /&&/span&
&span style="color: #007700"&echo&&/span&
&span style="color: #DD0000"&'ddd'&/span&
&span style="color: #007700"&;&br /&&/span&&span
style="color: #0000BB"&?&&br /&&/span&
在浏览器中的显示效果
4、查看php手册
从php5.1.2开始,程序员们可以在php命令行下查看手册了,输入php –rf function。会打印出该函数的语法简介
-bash-3.2$ php --rf strip_tags
Function [ &internal:standard& function strip_tags ] {
- Parameters [2] {
Parameter #0 [ &required& $str ]
Parameter #1 [ &optional& $allowable_tags ]
如果要查看类使用 –rc;查看扩展使用 –re。
Php命令行的使用方法介绍到这里就结束了。Enjoy It!
php - Unix, Linux Command
php - PHP Command Line Interface ’CLI’
php [options] [ -f ] file [[--] args...]
php [options] -r code [[--] args...]
php [options] [-B code] -R code [-E code] [[--] args...]
php [options] [-B code] -F file [-E code] [[--] args...]
php [options] -- [ args...]
php [options] -a
DESCRIPTION
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. This is the command line interface that enables you to do the following:
You can parse and execute files by using parameter -f followed by the name of the file to be executed.
Using parameter -r you can directly execute PHP code simply as you would do inside a .php file when using the eval() function.
It is also possible to process the standard input line by line using either the parameter -R or -F. In this mode each separate input line causes the code specified by -R or the file specified by -F to be executed. You can access the input line by $argn. While processing the input lines $argi contains the number of the actual line being processed. Further more the parameters -B and -E can be used to execute code (see -r) before and after all input lines have been processed respectively. Notice that the input is read from STDIN and therefore reading from STDIN explicitly changes the next input line or skips input lines.
If none of -r -f -B -R -F or -E is present but a single parameter is given then this parameter is taken as the filename to parse and execute (same as with -f). If no parameter is present then the standard input is read and executed.
Description
--interactive -a
Run PHP interactively. This lets you enter snippets of PHP code that directly get executed. When readline support is enabled you can edit the lines and also have history support.
--bindpath address:port|port -b address:port|port
Bind Path for external FASTCGI Server mode (CGI only).
--no-chdir -C
Do not chdir to the script’s directory (CGI only).
--no-header -q
Quiet-mode. Suppress HTTP header output (CGI only).
--timing count -T count
Measure execution time of script repeated count times (CGI only).
--php-ini path|file -c path|file
Look for php.ini file in the directory path or use the specified file
--no-php-ini -n
No php.ini file will be used
--define foo[=bar] -d foo[=bar]
Define INI entry foo with value bar
Generate extended information for debugger/profiler
--file file -f file
Parse and execute file
--global name -g name
Make variable name global in script.
--hide-args -H
Hide script name (file) and parameters (args...) from external tools. For example you may want to use this when a php script is started as a daemon and the command line contains sensitive data such as passwords.
PHP information and configuration
--syntax-check -l
Syntax check only (lint)
--modules -m
Show compiled in modules
--run code -r code
Run PHP code without using script tags ’&?..?&’
--process-begin code -B code
Run PHP code before processing input lines
--process-code code -R code
Run PHP code for every input line
--process-file file -F file
Parse and execute file for every input line
--process-end code -E code
Run PHP code after processing all input lines
--syntax-highlight -s
Output HTML syntax highlighted source
--version -v
Version number
--stripped -w
Output source with stripped comments and whitespace
--zend-extension file -z file
Load Zend extension file
Arguments passed to script. Use ’--’ args when first argument starts with ’-’ or script is read from stdin
--rfunction
name Shows information about function name
name Shows information about class name
--rextension
name Shows information about extension name
--rextinfo
name Shows configuration for extension name
Show configuration file names
Description
php-cli.ini
The configuration file for the CLI version of PHP.
The standard configuration file will only be used when php-cli.ini cannot be found.
Description
php -r ’echo "Hello World\n";’
This command simply writes the text "Hello World" to standard out.
php -r ’print_r(gd_info());’
This shows the configuration of your gd extension. You can use this to easily check which image formats you can use. If you have any dynamic modules you may want to use the same ini file that php uses when executed from your webserver. There are more extensions which have such a function. For dba use: php -r ’print_r(dba_handlers(1));’
php -R ’echo strip_tags($argn)."\n";’
This PHP command strips off the HTML tags line by line and outputs the result. To see how it works you can first look at the following PHP command 'php -d html_errors=1 -i' which uses PHP to output HTML formatted configuration information. If you then combine those two 'php ...|php ...' you’ll see what happens.
php -E ’echo "Lines: $argi\n";’
Using this PHP command you can count the lines being input.
php -R ’@$l+=count(file($argn));’ -E ’echo "Lines:$l\n";’
In this example PHP expects each input line being a file. It counts all lines of the files specified by each input line and shows the summarized result. You may combine this with tools like find and change the php scriptlet.
php -R ’echo "$argn\n"; fgets(STDIN);’
Since you have access to STDIN from within -B -R -F and -E you can skip certain input lines with your code. But note that in such cases $argi only counts the lines being processed by php itself. Having read this you will guess what the above program does: skipping every second input line.
You can use a shebang line to automatically invoke php from scripts. Only the CLI version of PHP will ignore such a first line as shown below:
#!/bin/php
// your script
You can view the list of known bugs or report any new bug you found at:
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
Additional work for the CLI sapi was done by Edin Kadribasic, Marcus Boerger and Johannes Schlueter.
A List of active developers can be found here:
And last but not least PHP was developed with the help of a huge amount of contributors all around the world.
VERSION INFORMATION
This manpage describes php, version 5.2.17.
Copyright (C)
The PHP Group
浏览 16072
echo 中文时在 cmd 下乱码,求解。有使用 UTF-8吗?
浏览: 8103631 次
来自: 洛杉矶
我想问下那个111.1是怎么得来的
楼上这里错了BITMAP_&TYPT&_B ...
写的非常好{=VLOOKUP($A11&$B11,IF({1,0},$A$2:$A$839!$B$2:$B$839,C$2:C$839),2,0}这个公式什么意思{=VLOOKUP($A11&$B11,IF({1,-知识宝库
你可能对下面的信息感兴趣

我要回帖

 

随机推荐