当前位置:首页 > PHP语言基础
实验二 PHP语言基础
1、 实验目的和要求
(1) 熟悉PHP语句在HTML中的嵌入位置; (2) 熟悉输出字符串的基本方法; (3) 熟悉PHP常量与预定义常量; (4) 熟悉PHP变量与相关函数; (5) 熟悉PHP常见的数据类型; (6) 掌握字符串及相关函数; (7) 熟悉PHP的运算符;
(8) 掌握PHP的流程控制语句。
2、 实验环境
(1) PC机;
(2) 操作系统:Windows;
(3) Web服务器:Apache;数据库服务器:MySQL;语言解释器:PHP; (4) 以上软件的集成安装包:XAMPP或WampServer; (5) 开发工具:PhpStorm。 3、 实验内容
(1) 验证变量的输出方式; (2) 验证数据类型的比较;
(3) 综合运用所学知识实现要求的页面。 4、 实验实现过程
(1) 观察以下程序的输出,理解变量在字符串中的输出方法:
var_dump(10==\var_dump(10.0==\var_dump(10===\ var_dump(1==TRUE); var_dump(1.5==TRUE); var_dump(\var_dump(\var_dump(\var_dump(\ (3) 综合练习:
根据大课所学的各项内容,在页面中显示如下效果:
要求:
a) 定义多个变量名带序号的变量,其值为序号。并把变量名和相应的
值显示在表格中;
b) 变量的个数由程序中的某个常量决定; c) 变量值为偶数的行,背景色为黄色。
小知识:Zen Coding
在页面中能输入HTML代码的地方输入: table>tr*5>td*2
再按 TAB 键,看能发现什么?
更多参考:https://code.google.com/p/zen-coding/
2
Zen Coding — a new way of writing HTML and CSS code
Follow us on Twitter @zen_coding
New version 0.7 is available (March 13, 2011), read release notes for more info.
Zen Coding is an editor plugin for high-speed HTML, XML, XSL (or any other structured code format) coding and editing. The core of this plugin is a powerful abbreviation engine which allows you to expand expressions—similar to CSS selectors—into HTML code. For example:
div#page>div.logo+ul#navigation>li*5>a
...can be expanded into:
Read more about current Zen Coding syntax
Abbreviation engine has a modular structure which allows you to expand abbreviations into different languages. Zen Coding currently supports CSS, HTML, XML/XSL and HAML languages via filters.
Current features of abbreviation engine
? ? ? ?
ID and CLASS attributes: div#page.section.main.
Custom attributes: div[title], a[title=\, td[colspan=2]. Element multiplication: li*5 will output
Item numbering with $ character: li.item$*3 will output
3
? ?
Multiple '$' characters in a row are used as zero padding, i.e.: li.item$$$ → li.item001 Abbreviation groups with unlimited
nesting: div#page>(div#header>ul#nav>li*4>a)+(div#page>(h1>span)+p*2)+d
iv#footer. You can literally write a full document markup with just a single line.
? ? ?
Filters support
div tag name can be omitted when writing element starting from ID or
CLASS: #content>.section is the same asdiv#content>div.section. (v0.7) Text support: p>{Click }+a{here}+{ to continue}.
To better understand how Zen Coding works, watch demo video and read Smashing Magazine tutorial. Zen Coding isn’t only a decent abbreviation engine, it also provides some very useful actions for HTML-coder’s every day needs, like: Wrap with Abbreviation, Tag Balancing, Toggle Comment, Remove Tag etc. Read more about available actions.
4
共分享92篇相关文档