Simple Q

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

Post Reply
vlads
Forum Newbie
Posts: 2
Joined: Sat Sep 12, 2009 11:03 am

Simple Q

Post by vlads »

Hello, I don't know so sure if it's ok to ask just a simple q, but I try so: What's the difference between:

Code: Select all

<?php $var['name']; ? >
and

Code: Select all

<?=$var['name']; ? >
and

Code: Select all

<?php echo $var['name']; ? >
,in a xhtml string. I'm asking this because in my scrip code I have the first version (<?php $var[name];?>) and it don't appear running localhost with easyphp, just if I put echo. Can it be a server problem or...? Because on the paid hosting server it is running.

Thanks, and hope to get an answ
(sorry for my bad engl)
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: Simple Q

Post by Darhazer »

<?php $var['name']; ? >
do nothing
<?=$var['name']; ? >
is the short version of
<?php echo $var['name']; ? >
The short version requires that short_open_tag is allowed
vlads
Forum Newbie
Posts: 2
Joined: Sat Sep 12, 2009 11:03 am

Re: Simple Q

Post by vlads »

Thanks for the fast reply.

I don't know how it works on the paid server, but I see that the whole script is written so:

Code: Select all

<td><a href="index.php?page=xxx&xxx=<?php $sc['xxx'];?>" class="xxx">&raquo; <?php $sc['xxx'];?></a></td>
 
                            </tr>
 
                            <tr>
 
                                <td class="xxx"><?php nl2br(substr($sc['xxx'], 0, 100));?> ...</td>
 
                            </tr>
 
...so how it's possible this?
Post Reply