今天我们参考php官方对php全局变量介绍来理解一下php全局变量一些用法与自己对它的一些思考吧,现在分享出来希望对各位同学有帮助。
一、核心要点思考:
1. 哪些全局变量是过期的及如何处理?
如:unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);
2. 哪些全局变量有命令行下是无效的?
3. htmlspecialchars()用法, 为什么要用它?
4. $_REQUEST和 $_GET, $_POST,$_COOKIE的联系与区别?
5. 为什么上传了文件但$_FILES变量不存在或为空?
6. 全局变量的作用域?
7. 我想取得用户的IP和浏览器的user_agent信息, 如何取?
8. 我没有用浏览器, 我是 socket编程? 如何保持session?
9. 如何取得headers信息?
php九大全局预定义数组
超全局变量 — 超全局变量是在全部作用域中始终可用的内置变量
$GLOBALS — 引用全局作用域中可用的全部变量
$_SERVER — 服务器和执行环境信息
$_GET — HTTP GET 变量
$_POST — HTTP POST 变量
$_FILES — HTTP 文件上传变量
$_REQUEST — HTTP Request 变量
$_SESSION — Session 变量
$_ENV — 环境变量
$_COOKIE — HTTP Cookies
$php_errormsg — 前一个错误信息
$HTTP_RAW_POST_DATA — 原生POST数据
$http_response_header — HTTP 响应头
$argc — 传递给脚本的参数数目
$argv — 传递给脚本的参数数组
二、主要问题
PHP基础篇总结题目:
1. var_dump(0=="ads");请问该条语句结果是怎样的?为什么?
答:此语句结果为true;
此表达式中右侧的字符串默认强制转换为int数据0,与左侧数据相同,所以输出true,如果是“===”,则会输出false,这是因为他们类型不同,值也不同,在这里不会强制转换。
点评:这个真不好说, 测试一下吧! var_dump()打印表达式的结果! 这个实际考的是表达式运算。
2.异常可以被克隆吗?
答:不可以。
3.PHP中 Traits有什么特性?
答:Traits (横向重用/多重继承)是一组结构很像类的方法,但它但不能实例化,它可以让开发人员在不同的类中轻松地重用方法;
Traits的最佳应用是多类之间可以共享相同的函数;静态变量可以被 trait 的方法引用,但不能被 trait 定义。但是 trait 能够为使用的类定义静态方法;如果 trait 定义了一个属性,那类将不能定义同样名称的属性,否则会产生一个错误;
总结:提的问题好,回答的也挺好
1、有哪些超全局变量?答:超全局变量:$GLOBALS、$_SERVER、$_GET、$_POST、$_FILES、$_COOKIE、$_SESSION、$_REQUEST、$_ENV
2、浏览器把cookie给禁用了,$_SESSION还能用吗? 答:不能用了
3、$php_errormsg在什么时候都可用吗?答:不是,这个变量只在错误发生的作用域内可用,并且要求track_errors配置项是开启的(默认是关闭的)。
有个人性化的面试问题
写30个php字符串函数。
实例如下:
- trim() 去掉字符串中的空格
- chop() 从右向左,删除指定字符 ,参数 rtrim(string,find);
- rtrim() 从右向左,删除指定字符 ,参数 rtrim(string,find);
- chr() 返回字符的 asc2 码
- var_dump() 打印一个值,可以是任何形式,并返回值的属性
- print() 打印数组或字符串
- print_r() 把字符串和数字简单地打印出来,而数组则以括起来的键和值得列表形式显示
- chunk_split() 把字符串分割为一连串更小的部分
- implode() 把数组元素组合为一个字符串
- join() 把数组元素组合为一个字符串
- explode() 把字符串分割成数组
- md5() 返回一个md5值,不可逆
- strlen() 获取一个字符串的长度
- str_replace 替换字符串中的一些字符
- mb_substr mb扩展的截取字符串函数,格式:
- mb_substr(string,start_Num,end_Num,'utf-8')
- str_split 将一个字符串按照字符间距分割为一个数组
- strpos 查找并返回首个匹配项的位置
- strtr 转换字符串中特定的字符
- substr 对字符串进行截取
- substr_count 计算字符串中某字符段的出现次数
- substr_replace 对字符串中的部分字符进行替换
- wordwrap 函数按照指定长度对字符串进行折行处理
- addcslashes() 在指定的字符前添加反斜杠
- strtolower() 把字符串转换为小写
- strtoupper() 把字符串转换为大写
- strrev() 反转字符串
- strripos() 查找字符串在另一字符串中最后出现的位置(大小写不敏感)
- strrpos() 查找字符串在另一字符串中最后出现的位置(大小写敏感)
- strspn() 返回在字符串中包含的特定字符的数目
- ucwords() 把字符串中每个单词的首字符转换为大写
- str_repeat() 把字符串重复指定的次数
1、命名空间必须是程序脚本的第一条语句吗?
答案:yes
2、如何取消引用?
答案:unset();
3、如果一个类,它里面至少有一个方法是被声明为抽象的,那么这个类就必须被声明为抽象类吗?继承一个抽象类的时候,子类必须定义父类中的所有抽象方法吗?
答案:如果一个类中有抽象方法,类必须定义为抽象类,继承一个抽象类时,子类必须定义父类中的所有抽象方法。
1.如何得到文件的绝对路径
使用realpath() 函数,返回绝对路径名。若失败,则返回 false,比如说文件不存在。
echo realpath("test.txt");
输出:C:wwwtestwebtest.txt
2.session的工作原理
session保存在服务端,但会以cookie的形式保存在客户端一个sessionid,如果禁用cookie,就需要用get方法的URL重写的机制或使用POST方法提交隐藏表单的形式来实现。
点评: 是这个原理, 但一般有web服务器会自动完成这个功能, 不需要在程序中添加。
3.public static声明的函数是静态方法吗?
public static声明的函数是静态方法,可以直接在类外用,类名::函数名的方法调用 不用采用NEW声明的方式
注意:函数内不能有动态内容 如$this->之类的,一般来说 需要频繁执行的内容 用STATIC声明
总结:session的工作原理整理的很好,分析很透彻。希望以后积极点,继续努力
波比源码 » php全局变量之学习笔记
levofloxacin pill cost levofloxacin 250mg
buy avodart 0.5mg generic ondansetron order online buy ondansetron pill
order spironolactone 25mg generic order valacyclovir 1000mg pill order generic diflucan 100mg
acillin generic cephalexin pills erythromycin 250mg cheap
purchase sildenafil online bimatoprost price methocarbamol 500mg for sale
suhagra 100mg us aurogra online order brand estradiol 1mg
buy lamotrigine 50mg generic buy vermox 100mg generic generic retin
purchase tadalis online cost tadacip diclofenac 50mg us
cheap indomethacin 75mg indomethacin 75mg tablet buy trimox online
arimidex 1mg oral Approved viagra pharmacy us viagra
acheter du cialis viagra 50mg sans ordonnance en france viagra 100mg pas cher
purchase prednisone viagra 100mg england sildenafil 50mg usa
order generic provigil 100mg Price cialis diamox 250 mg generic
altace 10mg over the counter order avapro buy azelastine 10ml online
purchase buspar oral ditropan 5mg order oxybutynin 5mg pills
fosamax 35mg generic cheap famotidine 20mg buy famotidine 40mg pills
order generic benicar 20mg calan 240mg pills order diamox 250mg
oral prograf 1mg order ursodiol 300mg for sale buy ursodiol 300mg for sale
zyban 150 mg ca order cetirizine 10mg order quetiapine without prescription
imuran 100 mcg pills order salbutamol 100mcg for sale order sildenafil 50mg generic
buy cialis 20mg without prescription fluoxetine 40mg brand cheap sildenafil without prescription
medroxyprogesterone buy online periactin online order buy cyproheptadine 4mg sale
buy modafinil 200mg online modafinil online order stromectol for sale
fluvoxamine 100mg tablet purchase cymbalta without prescription purchase glucotrol
accutane 10mg for sale buy generic accutane purchase deltasone
piracetam medication nootropil 800mg sale sildenafil 25mg for sale
cialis for sale tadalafil india sildenafil pharmacy
order lasix 100mg pills doxycycline 200mg us buy plaquenil 400mg online
buy itraconazole 100 mg sale buy progesterone generic tinidazole 300mg pills
order generic metformin 1000mg cheap tadalafil generic buy tadalafil 40mg sale
zyprexa 10mg price purchase bystolic pills order diovan 80mg generic
buy zyvox 600mg without prescription buy zyvox 600 mg generic online slot machines
oral omeprazole best poker online real money slots free
metoprolol 50mg for sale buy metoprolol generic vardenafil pills
buy priligy pills buy cytotec generic order synthroid 75mcg generic
order cialis 10mg pills tadalafil 10mg for sale buy viagra 100mg sale
xenical 120mg usa purchase diltiazem for sale cost acyclovir
tadalafil women buy inderal 10mg order plavix 150mg pill
zyloprim 300mg cheap order generic ezetimibe brand ezetimibe
order motilium pill order motilium 10mg without prescription generic cyclobenzaprine 15mg
buy cozaar generic order nexium 20mg pill order topamax 100mg for sale
buy imitrex 50mg for sale avodart 0.5mg sale buy avodart 0.5mg generic
oral zantac 300mg mobic 15mg brand buy celebrex 200mg online
cialis 40mg over the counter cipro 1000mg oral cipro ca
generic diflucan 100mg order sildenafil for sale sildenafil tablets
buy keflex pills buy cephalexin 250mg sale oral erythromycin 250mg
oral cialis 20mg buy sildenafil 100mg online cheap sildenafil for women
viagra 50mg oral sildenafil 100mg generic order tadalafil for sale
buy ceftin for sale buy robaxin pills robaxin price
sildenafil 50mg tablets order estradiol 2mg without prescription lamotrigine 200mg tablet
real casino new ed pills us cialis sales
azithromycin without prescription purchase prednisolone sale gabapentin buy online
cost furosemide buy doxycycline 100mg purchase hydroxychloroquine without prescription
buy fildena 100mg sale sildenafil without prescription order rhinocort online cheap
buy generic tretinoin cream tretinoin order avanafil 200mg cheap
tadalafil 20mg drug buy indomethacin 50mg indomethacin 75mg sale
purchase terbinafine online buy lamisil online cost trimox 500mg
buy clarithromycin 250mg meclizine order online order antivert 25mg for sale
order tiotropium bromide 9mcg terazosin 1mg usa buy hytrin sale
order pioglitazone 30mg online buy pioglitazone 15mg pill price viagra
free casino games no registration no download free roulette games roulette games
best casinos online roulette for real money college paper help
professional letter writing services arava medication order azulfidine 500 mg sale
doxycycline 100mg drug clindamycin ca order cleocin 150mg pill
acetazolamide 250 mg brand imuran online buy azathioprine for sale
order coreg for sale elavil price purchase amitriptyline online
oral amoxicillin 1000mg stromectol 6mg over the counter stromectol 6 mg dosage
Great post thank you. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
buy fosamax 70mg online ibuprofen 400mg pills order ibuprofen 600mg pill
dapoxetine 90mg drug buy avanafil online buy motilium 10mg without prescription
nortriptyline online buy paracetamol 500 mg ca cheap paroxetine 20mg
indomethacin capsule tamsulosin over the counter cenforce 100mg ca
generic doxycycline purchase doxycycline sale medrol 16 mg over the counter
Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
tadalafil for sale online order tadacip amoxicillin 500mg over the counter
I really love to read such an excellent article. Helpful article. Hello Administ . Metropol Halı Karaca Halı Öztekin ve Selçuklu Halı Cami Halısı ve Cami Halıları Türkiye’nin En Büyük Cami Halısı Fabrikasıyız…
order esomeprazole 20mg generic buy lasix pill buy furosemide online
buy tadalafil 10mg pill Cialis by mail sildenafil tablets
minocycline 100mg tablet cheap generic neurontin terazosin 5mg cheap
buy tadalafil 40mg online Mail order cialis ed remedies
clomiphene 100mg generic clomiphene 100mg price prednisolone 10mg generic
prednisone 5mg generic amoxicillin ca amoxicillin 1000mg without prescription
buy isotretinoin 40mg pill cost deltasone 5mg buy ampicillin 500mg pills
sildenafil 50mg without prescription pregabalin ca buy finasteride 1mg online
order zofran generic amoxil for sale buy trimethoprim without prescription
ventolin over the counter amoxiclav price order augmentin 375mg
cheap modafinil purchase modafinil generic cheap lopressor
purchase prednisolone pills gabapentin 600mg us lasix for sale online
generic doxycycline 200mg zovirax tablet acyclovir 800mg pill
generic imuran 50mg order generic imuran 25mg buy naprosyn 250mg generic
alfuzosin 10mg pills order alfuzosin 10 mg generic buy diltiazem 180mg generic
order levaquin 500mg pills order bupropion 150mg online zyban oral
coumadin us order generic zyloprim 100mg allopurinol 100mg us
generic zyrtec strattera 25mg over the counter buy zoloft 100mg without prescription
lexapro 10mg ca lexapro drug buy naltrexone without prescription
atorvastatin 20mg price purchase lipitor online order sildenafil 50mg pill
discount cialis real cialis online red ed pill
buy ivermectin 6 mg for humans buy isotretinoin online cheap isotretinoin 40mg cheap
amoxil 500mg over the counter zithromax generic buy prednisolone 20mg pills
buy accutane pills for sale amoxicillin 500mg pills where to buy azithromycin without a prescription
purchase albuterol pill ventolin generic levothyroxine order
buy tenormin 50mg generic letrozole 2.5 mg us buy letrozole 2.5mg without prescription
buy generic levothyroxine brand vardenafil vardenafil without prescription
glycomet drug order atorvastatin 20mg online buy amlodipine 5mg without prescription
order methotrexate 10mg without prescription medex generic reglan usa
purchase xenical without prescription order xenical 120mg online allopurinol cheap
tetracycline 250mg oral flexeril 15mg uk ozobax pill
toradol 10mg sale cost gloperba inderal order online
order plavix 150mg generic clopidogrel 150mg oral order nizoral online
buy tamsulosin sale buy flomax 0.2mg online buy spironolactone without prescription
cymbalta 40mg cheap buy glipizide 10mg generic buy piracetam online
combivent 100 mcg pills combivent 100mcg brand cost zyvox 600mg
starlix 120 mg us order candesartan 8mg pill order candesartan 8mg generic
nebivolol 20mg ca buy clozapine online cheap order clozaril 100mg pills
order zocor pill generic valacyclovir 1000mg buy viagra tablets
tadalafil 10mg generic free trial of cialis sildenafil 25mg for sale
fluconazole without prescription ciprofloxacin pills buy ciprofloxacin 1000mg without prescription
mebendazole buy online buy tadalafil 10mg pills order generic tadalis 10mg
tamoxifen 20mg oral tamoxifen us buy ceftin
where can i buy trimox order clarithromycin 250mg pills buy clarithromycin 250mg without prescription
suhagra online order where to buy aurogra without a prescription sildalis online order
ivermectin 3mg tablet order prednisone 10mg generic buy prednisone without prescription
buy generic furosemide lasix canada order ventolin inhalator
buy generic levitra online purchase levitra generic order hydroxychloroquine generic
ramipril 10mg uk order generic arcoxia 120mg etoricoxib pills
levitra 10mg for sale buy plaquenil for sale purchase hydroxychloroquine generic
buy mesalamine 400mg sale cheap avapro 150mg order irbesartan 300mg for sale
benicar oral buy divalproex 500mg online depakote 250mg over the counter
buy clobetasol cream buy amiodarone online cheap order amiodarone sale
buy diamox 250mg pills order isosorbide sale cheap azathioprine 25mg