View previous topic :: View next topic |
Author |
Message |
k1ll3rdr4g0n -
Joined: 04 Jul 2004 Posts: 609
|
Posted: Wed Aug 17, 2005 9:59 am Post subject: Proper PHP scripting? |
|
|
Which one would be more correct?
Code: | $temp = "cool";
echo "This is a $temp script";
|
or..
Code: | $temp = "cool";
echo "This is a" . $temp . " script";
|
Both will produce the same output, at least on on my configuration of PHP. _________________
|
|
Back to top |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Wed Aug 17, 2005 11:31 am Post subject: Re: Proper PHP scripting? |
|
|
k1ll3rdr4g0n wrote: | Which one would be more correct?
Code: | $temp = "cool";
echo "This is a $temp script";
|
or..
Code: | $temp = "cool";
echo "This is a" . $temp . " script";
|
Both will produce the same output, at least on on my configuration of PHP. |
either, it doesnt matter
but if you want to save typing use the first one _________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
|
cmxflash -
Joined: 11 Dec 2004 Posts: 872
|
Posted: Wed Aug 17, 2005 11:50 am Post subject: |
|
|
I would say...
Code: | $temp = "cool";
echo "This is a" . $temp . " script"; |
|
|
Back to top |
|
|
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Wed Aug 17, 2005 12:01 pm Post subject: |
|
|
cmxflash wrote: | I would say...
Code: | $temp = "cool";
echo "This is a" . $temp . " script"; |
|
Me too, as I think the first is a little crude. It seems to me that method was put in more for convienience than anything else. _________________
|
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Wed Aug 17, 2005 1:09 pm Post subject: |
|
|
Both are correct. But the first method seems to be faster (well, you won't notice the difference unless you have to make 10000s of calls to this line in the same script). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Aug 18, 2005 3:36 pm Post subject: |
|
|
Its always a good idea to use Concatenation when developing your scripts to
prevent problems later in future development , I would say the second but as
Aprelium explained , it really doesn't matter , its up to you. LateR!
Here's An Example
Code: |
<?php
// Start the name function
function name() {
$name = "Foo";
return $name;
}
// Example 1 , will print your name
echo "Your name is " . name();
// Example 2 , will not print out your name
// because your not seperating the string.
echo "Your name is name()";
?> |
P.S. Im leaving to Pittsburgh, PA in about an hour from now. :-)
Sincerely , TRUSTpunk |
|
Back to top |
|
|
k1ll3rdr4g0n -
Joined: 04 Jul 2004 Posts: 609
|
Posted: Thu Aug 18, 2005 11:14 pm Post subject: |
|
|
TRUSTpunk wrote: | Its always a good idea to use Concatenation when developing your scripts to
prevent problems later in future development , I would say the second but as
Aprelium explained , it really doesn't matter , its up to you. LateR!
Here's An Example
Code: |
<?php
// Start the name function
function name() {
$name = "Foo";
return $name;
}
// Example 1 , will print your name
echo "Your name is " . name();
// Example 2 , will not print out your name
// because your not seperating the string.
echo "Your name is name()";
?> |
P.S. Im leaving to Pittsburgh, PA in about an hour from now. :-)
Sincerely , TRUSTpunk |
I know for something like that, but I would script like this:
Code: | function name() {
$name = "Foo";
return $name;
}
$var = name();
echo "your name is $var.";
|
_________________
|
|
Back to top |
|
|
|