Php programming: why this function doesnt work?
-
<?php $d1="hello"; $t4="yes"; $t5="ok"; function abc($a,$b,$c) { if ($b="") { $c=$a; } else { $c=$b; } } abc($d1,$t3,$o1); abc($d2,$t4,$o2); abc($d3,$t5,$o3); echo $o1; echo $o2; echo $o3; ?>
-
Answer:
function doesn't return values........make the variebles global
Author at Yahoo! Answers Visit the source
Other answers
If you are trying to compare $b to an empty string, then you need to make that if($b == "") At the moment you are setting $b to an empty string. I hope this isn't homework!
diversenz
poojitra is right. what you send to the function are copies of your parameters, and what you change inside the function are not originals, but copies. you can do this: function abc($a, $b) { if ($b == "") $c=$a; else $c=$b; return $c; } $o2 = abc($d2, $t5); $o3 = abc($d3, $t5); better than making variables global IMHO
Bruno
COZ THERE ARE ONLY TWO QUESTION THERE & THE OTHER ONE IS BETTER
Sarang
Related Q & A:
- Why doesn't it work when I want to click a link in my Yahoo mess list?Best solution by Yahoo! Answers
- Why won't MoparScape work?Best solution by moparscape.org
- What do you do if a ds game doesnt work it wont read the data?Best solution by Yahoo! Answers
- Jailbreakme.com doesnt work?Best solution by youtube.com
- Msn plus doesnt work at all?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.