Single & Double Quotes
For me, single quotes is more faster than using a double quotes. I will try to explain it in my example.
echo '$var - static text here'; // Output: $var - static text here. $var2 = "Rob"; echo "$var2 - static text here."; // Output: Rob - static text here.
As you can see in a single quotes it will not read the variable so it will run fast. Im not telling you not to use double quotes but avoid it as possible.
Arithmetic
Okay, we will use some shortcut here.
$var = $var + 1; $var2 = $var2 - 1;
Is the same as:
$var ++; // or $var2 --;
Control Structure
You can see here the normal if else statement.
if( $name == 'rob' ) {
echo 'Rob';
} else {
echo 'Not Rob';
}
The other statement that will do same result.
echo ( $name == 'rob' ) ? 'Rob' : 'Not Rob';
Concatenation
This example is an email message code.
$message = "Greetings $user, nn"
."We have contacted you. n"
."You have won!n"
."and taking all your assets.nn"
."Thank you ";
Also, use tabs instead of space in formatting your code. Thats all. Hopefully you learn something in this post :).
Post to: BlinkBits BlogMarks Del.icio.us Digg Fark Furl Google Ma.gnolia MyWeb Netscape NetVouz Newsvine RawSugar Reddit Scuttle Shadows Simpy Slashdot Spurl Technorati Wists
Wednesday, June 24th, 2009
Comments
![]() |
Do you have any suggestions? Add your comment. Please don't spam! Subscribe to my feed |
please teach me robert concha to create a php website.. because we are neighbors..heheehehe thats all... go for gold to your carreer as a programmer of the year..
Good stuff! Single quotes are also nice because they allow you to easily output html if you are using php to dynamically do so without having to escape out the quotes.
echo '';
instead of...
echo "";
I don't get the first point. you use static text with the single-quote only.. yeah it will be faster when use it without a var in it then with one. but it doesnt make a difference how you quote that.
You dont even use (your) single-quotes in the last example..
good on ya!
Nice...
useful kaayo sir imu mga TIPS... para madali ang pag code namu.. student pa man gud ko sir.... thank you sa mga tips.. tana daghan pa mga tips puhon...
Maghimo pako daghan tutorial, pero sa karon medyo busy pako. Mag Update rako sunod pag makalugar. Kabalo diay ka PHP? Asa ka nag skul?
STI sir... pero naningkamot ra ko sir makabalo.... sa imu ra ko mga tips nag sunod.... kaila mi ni IAN...
When po pwede maki pag laro sa inyo???
Ajaw na pag sir sa ako.. maulaw man sab ta.. mag dula rata kanang dili ta pareho busy..
Regards
aw cge.. robert rakan.... isa man ako sa OJT njo sa sa SIM hehehehehe
RH RH RH! . haha 2kyOd!!
robert please pag add pa lain mga tips...
sir unsaon man pag gamit sa $_post and $_get sa php?
just asking sir for my site, kulang man gud ko php para sa comments. hope sir u can help me. thnks.
Write a comment
* = required field
Save to del.icio.us 