PHP ?????????

???????? ?????
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

Re: PHP ?????????

Post by Face » Wed Nov 03, 2010 7:36 pm

??? NEO ?????? ????,

????? ??? ?????? code ??,???? ??????? ????? ?? ??? ????.fun ? ????.

Code: Select all

<html>
<body>

<?php
$d=date("D");
echo ("today is")."".$d;
?>

</body>
</html> 
priview

Code: Select all

today isWed 
???? ????
User avatar
Neo
Site Admin
Site Admin
Posts: 2642
Joined: Wed Jul 15, 2009 2:07 am
Location: Colombo

Re: PHP ?????????

Post by Neo » Wed Nov 03, 2010 7:40 pm

There are 2 differences between echo and print in PHP:
  • print returns a value. It always returns 1.
  • echo can take a comma delimited list of arguments to output.
Always returning 1 doesn't seem particularly useful. And a comma delimited list of arguments can be simulated with multiple calls or string concatenation. So the choice between echo and print pretty much comes down to style. Most PHP code that I've seen uses echo.

printf() is a direct analog of C's printf(). If you're comfortable in the c idiom, you might use printf(). A lot of people in the younger generation though, find printf()'s special character syntax to be less readable than the equivalent echo code.

There are probably differences in performance between echo, print and printf, but I wouldn't get too hung up on them since in a database driven web application (PHP's typical domain), printing strings to the client is almost certainly not your bottleneck. The bottom line is that any of the 3 will get the job done and one is not better than another. It's just a matter of style.

In simple terms, USE echo :)
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

Re: PHP ?????????

Post by Nipuna » Wed Nov 03, 2010 8:19 pm

Macho Ube Code eka Ela.

mama Podi Correction ekak karata Kamam Ne Ne. :)

Ube

Code: Select all

 today isWed 
Wela tiynenne uba Menna Metana

Code: Select all

echo ("today is")."".$d;

Code: Select all

."".
Oya Koma Deka Meda Scace ekak tiyapan Me wage etakota Hariyate me wage enawa.

Code: Select all

." ".

Code: Select all

 today is Wed 
Hari Neda? Kamak Ne ne Meka Pennala Dunnata? Awulak Ne Ne? :)
User avatar
Face
Major
Major
Posts: 727
Joined: Thu Feb 18, 2010 5:06 pm
Location: SRI LANKA.KANDY.

Re: PHP ?????????

Post by Face » Wed Nov 03, 2010 9:59 pm

?? ??.thanks ????.??? ???????.?????? ????? ???? ??? ????? ???? ??? ?????? ????? ??.???? ?????? ? ???????????? ??? ??? ???????????????.??? ???? friends.
?? post ??? codes ?? ????? ??? ??? ???? ?????? ??? ?? ??? ??????? ?????.
User avatar
Nipuna
Moderator
Moderator
Posts: 2729
Joined: Mon Jan 04, 2010 8:02 pm
Location: Deraniyagala,SRI LANKA

Re: PHP ?????????

Post by Nipuna » Wed Nov 03, 2010 10:16 pm

Mama Danna Ewa Tbunoth Mama Aniwa Help Karanawa :)

Thanks Man
Post Reply

Return to “???????? ?????”