Home Backend Development PHP Tutorial PHP开发的一些注意点总结_php技巧

PHP开发的一些注意点总结_php技巧

May 17, 2016 am 09:23 AM
php development

Linux系统的使用

现在标配的系统是 Linux + Nginx + PHP + MySQL ,这样的配置越来越多的大公司在用的了说到配置不同的是一个公司的规约,比如说挂载一般分为2个盘, / 下面划分为系统用的分区10G 足够 剩余空间划给/home的了.这点我感觉比较好的,原来我划的太多的了,其次是对于系统的安全登陆,现在小公司或者个人的做法是通过网络,直接使用帐号或者密码直接登陆而相对大公司的做法是,先登陆relay中转服务器,然后通过中转服务器登陆到目标服务器,这样帐号会被记录,安全性比较高,现在一般用了TOKEN,RSASecurID进行密码登陆,提高了整体的安全性了.



PHP调用shell命令

在之前没有使用到php调用到shell来执行一些额外的任务,现在会经常用到的了,这样就可以做脚本之外的事情了,这点感觉比较方便

编码习惯上对于编码习惯,每个公司和团队往往使用的都不同,特别是编程IDE的不同导致了编码规范的不同而约定也就不同的了,不过对于整体的习惯经过团队全体人员的决议,就定下来了,这点在原来的小公司没有要求的很严格,现在也是这样的,看来这个和团队文化还是有很大关系的了,这点团队的人相处久了,自然就熟悉的了.


函数返回值

一般对于获取失败的返回值都返回的是false,对于出现的多种情况,返回int的数值,如果是数据则返回的是array或者其他,对于现在的函数由于memcache的使用,现在用了很多的函数内的cache操作,返回值也是先从cache取得,如果没有在到数据库中取得,然后写入cache,然后返回数据

对于处理数据写入原来的写法是在$_POST && $_GET 过来的数据,然后进行addslashes处理,现在的做法是直接接收,然后进行数据判断是否符合要求,然后在拼接sql,然后对sql语句进行mysql_escape_string处理,然后在读出数据的时候,使用htmlspecialchars进行处理,这样显示就没有问题的了.



锁机制的PHP实现

前段时间写过一篇文章并发下常见的加锁及锁的PHP具体实现



关于队列的分发问题

使用了MQ进行Memcache数据的分发,这点还没弄明白,具体的实现,得在请教的了



关于PHP的错误级别的认识

原来对于错误级别,在开发的时候用的都是比较轻的E_ALL | E_STRICT 现在换成了E_ALL & ~E_STRICT 养成变量定义的好习惯,使用时候初始化是比较必要的.


对于防止用户发表违法信息及广告的控制及用户行为频率的控制

对于用户发布的广告,违法信息都用SPAM系统进行了控制,防止出现问题,对于用户行为进行了限制,防止用户过多的控制资源,对于系统中的变量不能使用自增的唯一ID,需要进行加密处理,返回系统信息被其他人获得.包括用户ID,数据信息ID的加密处理
Statement of this Website
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

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Memcache in PHP development? How to use Memcache in PHP development? Nov 07, 2023 pm 12:49 PM

In web development, we often need to use caching technology to improve website performance and response speed. Memcache is a popular caching technology that can cache any data type and supports high concurrency and high availability. This article will introduce how to use Memcache in PHP development and provide specific code examples. 1. Install Memcache To use Memcache, we first need to install the Memcache extension on the server. In CentOS operating system, you can use the following command

Teach you step by step to develop your own forum website using PHP Teach you step by step to develop your own forum website using PHP Oct 28, 2023 am 08:23 AM

With the rapid development of the Internet and people's increasing demand for information exchange, forum websites have become a common online social platform. Developing a forum website of your own can not only meet your own personalized needs, but also provide a platform for communication and sharing, benefiting more people. This article will teach you step by step how to use PHP to develop your own forum website. I hope it will be helpful to beginners. First, we need to clarify some basic concepts and preparations. PHP (HypertextPreproces

How to develop a hotel booking website using PHP How to develop a hotel booking website using PHP Oct 28, 2023 am 08:19 AM

How to use PHP to develop a hotel booking website With the development of the Internet, more and more people are beginning to arrange their travels through online booking. As one of the common online booking services, hotel booking websites provide users with a convenient and fast way to book hotels. This article will introduce how to use PHP to develop a hotel reservation website, allowing you to quickly build and operate your own online hotel reservation platform. 1. System requirements analysis Before starting development, we need to conduct system requirements analysis first to clarify what the website we want to develop needs to have.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to use PHP to develop an online tutoring service platform How to use PHP to develop an online tutoring service platform Oct 28, 2023 am 09:01 AM

How to use PHP to develop an online tutoring service platform. With the rapid development of the Internet, online tutoring service platforms have attracted more and more people's attention and demand. Parents and students can easily find suitable tutors through such a platform, and tutors can also better demonstrate their teaching abilities and advantages. This article will introduce how to use PHP to develop an online tutoring service platform. First, we need to clarify the functional requirements of the platform. An online tutoring service platform needs to have the following basic functions: Registration and login system: users can

How to implement version control and code collaboration in PHP development? How to implement version control and code collaboration in PHP development? Nov 02, 2023 pm 01:35 PM

How to implement version control and code collaboration in PHP development? With the rapid development of the Internet and the software industry, version control and code collaboration in software development have become increasingly important. Whether you are an independent developer or a team developing, you need an effective version control system to manage code changes and collaborate. In PHP development, there are several commonly used version control systems to choose from, such as Git and SVN. This article will introduce how to use these tools for version control and code collaboration in PHP development. The first step is to choose the one that suits you

How to use PHP to develop the coupon function of the ordering system? How to use PHP to develop the coupon function of the ordering system? Nov 01, 2023 pm 04:41 PM

How to use PHP to develop the coupon function of the ordering system? With the rapid development of modern society, people's life pace is getting faster and faster, and more and more people choose to eat out. The emergence of the ordering system has greatly improved the efficiency and convenience of customers' ordering. As a marketing tool to attract customers, the coupon function is also widely used in various ordering systems. So how to use PHP to develop the coupon function of the ordering system? 1. Database design First, we need to design a database to store coupon-related data. It is recommended to create two tables: one

How to use PHP to develop the member points function of the grocery shopping system? How to use PHP to develop the member points function of the grocery shopping system? Nov 01, 2023 am 10:30 AM

How to use PHP to develop the member points function of the grocery shopping system? With the rise of e-commerce, more and more people choose to purchase daily necessities online, including grocery shopping. The grocery shopping system has become the first choice for many people, and one of its important features is the membership points system. The membership points system can attract users and increase their loyalty, while also providing users with an additional shopping experience. In this article, we will discuss how to use PHP to develop the membership points function of the grocery shopping system. First, we need to create a membership table to store users

See all articles