Posted on February 2nd, 2010 by Jans
Recently one of my friend asked me to write a function in PHP for multiplying two numbers without * or / operators. Also we should not use any loops. I got the following solution.
function mul($a,$b)
{
if($b==1){return $a;}
return $a+mul($a,$b-1);
}
echo mul(5,6);
One more solution which i found is as follows. But is is using the division(/) operator.
function mul($a,$b)
{
return $a/(1/$b);
}
echo [...]
Filed under: PHP | No Comments »
Posted on January 7th, 2010 by Jans
Two Years back i have written a post about the MVC(Model-View-Controller) song in this blog. Yesterday while surfing the web I found a video of James singing it live on WWDC 2003 in youtube. Here is the youtube video:
And those who wish to read the lyrics, check it here… Song about MVC…..Yeah, yeah, yeah
.
Filed under: PHP, Web | No Comments »
Posted on June 18th, 2009 by Jans
Recently I have faced an issue with session in IFrames in IE Browsers. The issue is like session is not sharing between pages inside iframe particularly if you are accessing it in a different domain. The script will run smoothly without the iframe, but when i use the iframe in IE and safari it doesn’t [...]
Filed under: PHP, Security | No Comments »
Posted on August 12th, 2008 by Jans
echo is faster than print.
Wrap your string in single quotes (’) instead of double quotes (”) is faster because PHP searches for variables inside “…” and not in ‘…’, use this when you’re not using variables you need evaluating in your string.
Use echo’s multiple parameters (or stacked) instead [...]
Filed under: PHP, Tips & Tricks | 1 Comment »
Posted on June 25th, 2008 by Jans
Recently I faced a weird issue with the PHP header location function. I had a line of code in my file like,
Code: header(‘location:mypage.php’);
In firefox/geeko browsers it is working fine. but in IE when it tries to redirect the page it is showing a “page not found error”. I am pretty sure that the page is [...]
Filed under: PHP | No Comments »