search
HomeBackend DevelopmentPHP Tutorial1.0 EcShop开篇有益-序

         本文版权归李德全所有,转载请注明

    经过朋友点拨,老李找到一个Zend Studio的PHP开发平台,试用了一阵感觉还不错,基本上需要的功能都具备,就下定决心用它了。在ecshop的源文件中怎么也找不到工程文件,但这可难不到老李。商城的入口页面是index.php,那就先打开index.php文件,然后在开头的地方设个断点试试吧,结果还真行了。也许有的人要问,为什么不从架构讲起?为什么不从模板机制讲起?老李是这样想的,EcShop之路0.x的课程是讲一些开发的基本知识,如PHP、smarty、MySQL等,高手还是关注后续的EcShop架构篇吧!

         言归正传,在调试窗口老李看到了好多不认识的变量(如下图),哪里来的呢?干什么用的呢?


          下面要介绍一些基本知识。众所周知,任何开发语言都是有变量的(废话、呵呵),PHP也是一样。PHP变量分成两部分,一部分是用户自定义变量,变量间的赋值可以有值赋值和引用赋值(区别在是否共享内存)。另一部分就是我们下面要说的PHP预定义变量,通过操作PHP预定义变量,我们可以获取用户会话、用户操作系统的环境和本地操作系统的环境等信息。

变量名称

说明

$GLOBALS

是由所有已定义的全局变量组成的数组。变量名就是该数组的索引。它可以称得上是所有超级变量的超级集合

$_COOKIE

通过HTTPCookie传递到脚本的信息。这些Cookie多数是由执行PHP脚本时通过setcooke()函数设置的

$_ENV

执行环境提交至脚本的变量。类似于旧数组 $HTTP_ENV_VARS 数组(依然有效,但反对使用)

$_FILES

经由 HTTP POST 文件上传而提交至脚本的变量。类似于旧数组 $HTTP_POST_FILES 数组(依然有效,但反对使用)

$_GET

包含通过GET方法传递的参数的相关信息。主要用于获取通过GET方法提交的数据

$_POST

包含通过POST方法传递的参数的相关信息。主要用于获取通过POST方法提交的数据

$_REQUEST

经由 GET,POST 和 COOKIE 机制提交至脚本的变量,因此该数组并不值得信任

$_SERVER

由 Web 服务器设定或者直接与当前脚本的执行环境相关联的变量,例如服务器IP地址、主机名称等

$_SESSION

包含与所有会话变量有关的信息。主要应用于会话控制和页面之间值的传递。

         说完了预定义变量,老李突然觉得没有什么好讲的了。无非就是控制语句if...elseif…else,循环语句while,do…while,foreach等,但还是要提醒下大家,注意双引号和单引号的区别。至于cookie和session,在BS程序中无论采用哪种开发平台都是一个意思。好了,老李迫不及待的想去看看MySQL了。


1.0 EcShop开篇有益-序

1.1 EcShop之路-安装

1.2 EcShop之路-PHP

1.3 EcShop之路-MySQL

1.4 EcShop之路-Smarty

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
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

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 Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools