建站之三:PHP网页兑现
建站之三:PHP网页实现
一、相关概念
1. Php与Html关系
Html : 前端、静态、客户端执行
Php : 后端、动态、服务器执行
Html可以包含Php,Php可以生成html
2. Php与Javascript关系
Php是服务器端脚本,Javascript是客户端脚本,功能不同,可以配合使用
如在Form中button的onclick可以调Javascript函数,但不能调php函数
而Javascript不能处理服务器端数据
3. 网页术语
Css:控制网页内容如何显示
Div:Div标签用于定义一个区域的显示方式(如背景,字体,对齐方式等)
Style:Style标签用来设置css格式表
Meta:Meta标签包含一些网页的隐藏信息
二、网页实现
1. 建议使用DreamWeaver设计网页,然后再手动编辑
设置页面属性(背景,屏幕宽度,链接显示等),加入文字图片等
一般网站,需要设计页头,页脚(可单写文件,被多个页网包含)
2. 网页适应浏览器分析率
用百分比设置宽度:width:100%
设置最大宽度:max-width:800px
3. 网页适应Android手机分辨率(不影响电脑浏览器效果)
设置手机默认屏宽为320
4. 如何解决中文乱码问题?
乱码可能是由于浏览器未能识别HTML中的中文字符集造成的,需要在开头指定字符集,加入
或者
5. 如何在退回上一页时,记住上一页表单中之前的选择?
在上一页开头加入
header('Cache-control: private, must-revalidate'); ?>
6. 返回上一页按钮的实现
echo "
三、PHP实现
1. PHP的基本语法:类似C语言
2. PHP的注释:与C语言一样用//,/*,*/
3. PHP的调试:一般用echo,print_r()调试
4. PHP单引号和双引号的区别:双引号中的经过解释输出,单引号中的直接输出
5. PHP中函数的定义
function sum($a, $b) {
$c = $a + $b;
return $c;
}
返回值支持各种类型
6. 传递参数:使用GET方式传参
1) 调用端
echo "
2) 接收端
$value=$_GET["test"];
即可得到xxxxx
7. 如何回车
网页中的回车”
”
Html代码中回车是“\n”
8. 为什么有时候empty函数不能判断空值
值为空或为零时empty函数都返回真
四、调试注意事项
1. Android手机调试
最好在Android自带浏览器中调试,UC浏览器会记住用户缩放比例,可能导致歧义
2. 电脑调试
最好用IE6调试,旧浏览器能支持的,新浏览器一般都没问题(有些参数IE6不识别,有的PNG图片不透明)
五、参考
1. Html之表单
http://www.sj33.cn/jc/wyjc/htjc/200612/10726_2.html
2. 常用的表单中的button链接
http://www.cnblogs.com/infim/archive/2010/08/23/1806400.html
3. Php操作Mysql数据库
http://www.189works.com/article-49493-1.html
http://www.jb51.net/article/14668.htm
4. Php解析Xml
http://www.php100.com/html/webkaifa/PHP/PHPyingyong/2012/0110/9638.html
5. Android屏幕适配
http://mobile.51cto.com/web-316935.htm
6. 作者实现的网站
http://oatmental123.sinaapp.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.
