php函数的返回值.其实php函数可以返回一个或多个值,使用return关键字可以返回一个变量或者一个数组.return会使程序在return处停止,并返回指定的变量.今天举一个例子吧:
实例代码如下:
- ';
- function she($a,$b,$c)
- {
- return array($c,$b,$a);
- }
- list($x,$y,$z)=she(2,3,4);
- echo '$x='.$x.'$y='.$y.'$z='.$z;
- ?>
- 执行结果如:
- function add($shu)
- {
- return $shu+1;
- }
- echo add(2).'
- ‘;
- function she($a,$b,$c)
- {
- return array($c,$b,$a);
- }
- list($x,$y,$z)=she(2,3,4);
- echo ‘$x=’.$x.’
- $y=’.$y.’
- $z=’.$z;
- ?>
php函数,想要传回多个返回值,怎么做到(函数不能返回多个值,但可以通过返回一个数组来得到类似的效果.)
实例代码如下:
- <?php
- function results($string)
- {
- $result = array();
- $result[] = $string;//原字符串
- $result[] = strtoupper($string);//全部换成大写
- $result[] = strtolower($string);//全部换成小写
- $result[] = ucwords($string);//单词的首字母换成大写
- return $result;
- }
- $multi_result = results('The quick brown fox jump over the lazy dog');
- print_r($multi_result);
- ?>
- 输出结果:
- Array
- (
- [0] => The quick brown fox jump over the lazy dog
- [1] => THE QUICK BROWN FOX JUMP OVER THE LAZY DOG
- [2] => the quick brown fox jump over the lazy dog
- [3] => The Quick Brown Fox Jump Over The Lazy Dog
- )
引用,本函数返回三个值,一个是函数返回,两个传引用.
实例代码如下:
- test(&$a,&$b){
- $a = 1000;
- $b = 12000;
- return $a+$b;
- }
- $a = 10;
- $b = 12;
- $c = test($a,$b); //注意这里没有 & 了.
- //显示修改后的值
- echo $a;
- echo $b;
- echo $c; //这是函数返回值;
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » php函数的返回值
波比源码 » php函数的返回值
levofloxacin cheap buy levaquin 250mg without prescription
order avodart 0.5mg generic ondansetron 4mg tablet cost ondansetron 4mg
order aldactone 25mg online spironolactone 25mg drug diflucan 200mg brand
ampicillin uk cephalexin cost erythromycin 500mg usa
buy fildena 100mg for sale buy tamoxifen 20mg generic buy methocarbamol without prescription
suhagra 100mg cheap estradiol 2mg drug brand estrace 2mg
lamictal 200mg sale tretinoin gel canada tretinoin cream oral
buy tadalis 20mg generic tadacip pills cost voltaren
isotretinoin over the counter order amoxil 1000mg generic azithromycin tablet
purchase arimidex pills order anastrozole generic order sildenafil pills
vrai tadalafil 40mg prix vrai viagra prix acheter gГ©nГ©rique sildenafil en france
order prednisone 10mg without prescription cialis generic 10mg no rx sildenafil pills 25mg
accutane usa buy isotretinoin 20mg buy ivermectin 12mg
modafinil 100mg usa Buy cialis low price buy diamox 250mg sale
catapres brand purchase spiriva sale purchase tiotropium bromide generic
fosamax 35mg without prescription buy panadol 500 mg for sale pepcid sale
prograf 1mg drug buy ropinirole online cheap buy ursodiol pills
isosorbide 20mg for sale digoxin 2250 mg tablet cost micardis 20mg
brand salbutamol 100 mcg buy pantoprazole 20mg pills viagra sale
cialis 5mg us cialis professional sildenafil 20mg
tadalafil cost buy tadalafil pills symmetrel 100mg price
buy revia 50mg pills revia 50 mg cost cheap aripiprazole 20mg
order dapsone 100mg sale purchase aceon sale aceon order
oral modafinil 200mg modafinil 200mg uk stromectol liquid
fluvoxamine cost order luvox 50mg for sale glucotrol 5mg over the counter
buy nootropil 800mg for sale viagra uk buy viagra for sale
cost tadalafil real cialis pharmacy prescription buy viagra 50mg without prescription
cialis 20mg order generic anafranil 50mg order clomipramine 50mg pills
buy itraconazole 100 mg online cheap generic progesterone 100mg buy tindamax 500mg
order glucophage 1000mg generic lipitor 10mg usa cialis 40mg for sale
order sildenafil 100mg pill order generic lisinopril 5mg lisinopril cost
order omeprazole pills write thesis poker games online
metoprolol price tenormin 50mg price levitra 10mg price
my mother essay writing essays writing online casinos usa
purchase vardenafil online medrol buy online medrol 4 mg pills
order dapoxetine 60mg for sale cytotec online buy synthroid 150mcg without prescription
xenical 120mg pills buy acyclovir 400mg buy zovirax without prescription
tadalafil 5mg order cialis plavix 150mg brand
buy allopurinol 100mg generic rosuvastatin 10mg uk ezetimibe pills
methotrexate for sale online methotrexate 2.5mg price metoclopramide 10mg cost
purchase motilium pill oral flexeril 15mg cyclobenzaprine usa
sumatriptan 50mg pill imitrex 25mg cheap buy dutasteride generic
zantac 300mg generic buy zantac pills celecoxib 100mg over the counter
oral cialis 10mg order tadalafil 5mg pill order ciprofloxacin 1000mg generic
purchase metronidazole for sale augmentin cost trimethoprim price
order fluconazole 200mg viagra 100mg cheap buy generic sildenafil 50mg
order viagra 50mg pills tadalafil 5mg canada buy cialis 5mg sale
no deposit casino modafinil online buy order provigil 100mg online
order fildena buy generic tamoxifen budesonide for sale