PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
civrob
Forum Newbie
Posts: 1 Joined: Mon Jun 27, 2005 5:49 am
Post
by civrob » Mon Jun 27, 2005 5:56 am
The following works perfectly
Code: Select all
<input name="e;"e; type="e;submit"e; value="e;<?= $company_name?>"e;>
This does not? (closeses I get is)
Code: Select all
echo '<input name="" type="submit" value="' ,$company_name, '?>">';
I want to keep it all in php so when I come to do design in dreamweaver its just one block of code
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Mon Jun 27, 2005 6:01 am
You escaped your single quotes when you didn't have to.
Code: Select all
echo "<input name=\"\" type=\"submit\" value=\"$company_name\">";
// or //
echo '<input name="" type="submit" value="$company_name">';
harrisonad
Forum Contributor
Posts: 288 Joined: Fri Oct 15, 2004 4:58 am
Location: Philippines
Contact:
Post
by harrisonad » Mon Jun 27, 2005 6:15 am
civrob wrote:
Code: Select all
echo '<input name="" type="submit" value="' ,$company_name, '?>">';
- replace commas with periods
- you don't have to put closing tag inside a string.
Code: Select all
echo '<input name="" type="submit" value="'.$company_name.'">';
s.dot
Tranquility In Moderation
Posts: 5001 Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana
Post
by s.dot » Mon Jun 27, 2005 7:03 am
why even escape the echo?
' . $var . ' could just easily be $var
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Mon Jun 27, 2005 7:11 am
scrotaye wrote: why even escape the echo?
' . $var . ' could just easily be $var
Not in single quotes like he/she's using here... it wont parse. Same goes for your second example...
It's a matter of preference hwo you do it but *most* editors won't highlight the variable is you don't concatenate it into the string.
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Mon Jun 27, 2005 9:20 am
I usually write it as following:
Code: Select all
echo "<input name='name' type='submit' value='{$company_name}">';
in this case { } is not needed, but as soon as you have a variable like $row['column'] you'll appreciate it
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Mon Jun 27, 2005 11:40 am
my Favorite.
Code: Select all
<input name="name" type="submit" value="<?php echo $company_name;?>">