search
HomeBackend DevelopmentPHP Tutorial建站之三: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 "

\n";
echo "\n";
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 "

\n";
echo "\n";
echo "
\n";

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


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How can you check if a PHP session has already started?How can you check if a PHP session has already started?Apr 30, 2025 am 12:20 AM

In PHP, you can use session_status() or session_id() to check whether the session has started. 1) Use the session_status() function. If PHP_SESSION_ACTIVE is returned, the session has been started. 2) Use the session_id() function, if a non-empty string is returned, the session has been started. Both methods can effectively check the session state, and choosing which method to use depends on the PHP version and personal preferences.

Describe a scenario where using sessions is essential in a web application.Describe a scenario where using sessions is essential in a web application.Apr 30, 2025 am 12:16 AM

Sessionsarevitalinwebapplications,especiallyfore-commerceplatforms.Theymaintainuserdataacrossrequests,crucialforshoppingcarts,authentication,andpersonalization.InFlask,sessionscanbeimplementedusingsimplecodetomanageuserloginsanddatapersistence.

How can you manage concurrent session access in PHP?How can you manage concurrent session access in PHP?Apr 30, 2025 am 12:11 AM

Managing concurrent session access in PHP can be done by the following methods: 1. Use the database to store session data, 2. Use Redis or Memcached, 3. Implement a session locking strategy. These methods help ensure data consistency and improve concurrency performance.

What are the limitations of using PHP sessions?What are the limitations of using PHP sessions?Apr 30, 2025 am 12:04 AM

PHPsessionshaveseverallimitations:1)Storageconstraintscanleadtoperformanceissues;2)Securityvulnerabilitieslikesessionfixationattacksexist;3)Scalabilityischallengingduetoserver-specificstorage;4)Sessionexpirationmanagementcanbeproblematic;5)Datapersis

Explain how load balancing affects session management and how to address it.Explain how load balancing affects session management and how to address it.Apr 29, 2025 am 12:42 AM

Load balancing affects session management, but can be resolved with session replication, session stickiness, and centralized session storage. 1. Session Replication Copy session data between servers. 2. Session stickiness directs user requests to the same server. 3. Centralized session storage uses independent servers such as Redis to store session data to ensure data sharing.

Explain the concept of session locking.Explain the concept of session locking.Apr 29, 2025 am 12:39 AM

Sessionlockingisatechniqueusedtoensureauser'ssessionremainsexclusivetooneuseratatime.Itiscrucialforpreventingdatacorruptionandsecuritybreachesinmulti-userapplications.Sessionlockingisimplementedusingserver-sidelockingmechanisms,suchasReentrantLockinJ

Are there any alternatives to PHP sessions?Are there any alternatives to PHP sessions?Apr 29, 2025 am 12:36 AM

Alternatives to PHP sessions include Cookies, Token-based Authentication, Database-based Sessions, and Redis/Memcached. 1.Cookies manage sessions by storing data on the client, which is simple but low in security. 2.Token-based Authentication uses tokens to verify users, which is highly secure but requires additional logic. 3.Database-basedSessions stores data in the database, which has good scalability but may affect performance. 4. Redis/Memcached uses distributed cache to improve performance and scalability, but requires additional matching

Define the term 'session hijacking' in the context of PHP.Define the term 'session hijacking' in the context of PHP.Apr 29, 2025 am 12:33 AM

Sessionhijacking refers to an attacker impersonating a user by obtaining the user's sessionID. Prevention methods include: 1) encrypting communication using HTTPS; 2) verifying the source of the sessionID; 3) using a secure sessionID generation algorithm; 4) regularly updating the sessionID.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools