Proper PHP scripting?

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
k1ll3rdr4g0n
-


Joined: 04 Jul 2004
Posts: 609

PostPosted: Wed Aug 17, 2005 9:59 am    Post subject: Proper PHP scripting? Reply with quote

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 View user's profile Send private message AIM Address
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Wed Aug 17, 2005 11:31 am    Post subject: Re: Proper PHP scripting? Reply with quote

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 View user's profile Send private message Visit poster's website
cmxflash
-


Joined: 11 Dec 2004
Posts: 872

PostPosted: Wed Aug 17, 2005 11:50 am    Post subject: Reply with quote

I would say...

Code:
$temp = "cool";
echo "This is a" . $temp . " script";
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Wed Aug 17, 2005 12:01 pm    Post subject: Reply with quote

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 View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Wed Aug 17, 2005 1:09 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Aug 18, 2005 3:36 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
k1ll3rdr4g0n
-


Joined: 04 Jul 2004
Posts: 609

PostPosted: Thu Aug 18, 2005 11:14 pm    Post subject: Reply with quote

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 View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group