Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 5:13 PM   #1
The Plankmeister
 
The Plankmeister's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

Hi...

I seem to remember reading somewhere about the proper way of doing this sort
of thing in the middle of some html, for example:

<a href="<?= $some_url_or_other ?>">Click this!</a>

What is the most proper way of doing such? Would it be to do the full
monty?:

<a href="<?php echo $some_url_or_other ?>">Click this!</a>

I am writing my output to be xhtml strict compliant, so I guess for
continuity alone it should be the latter, but are there any specific reasons
for using the long-winded way? I'd like to know people's thoughts...

HYCSSLOTS...


Plankmeister.


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 5:13 PM   #2
E-Star
 
E-Star's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

In article <3f41d39e$0$32454$edfadb0f@dread16.news.tele.dk> , The
Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:

> <a href="<?php echo $some_url_or_other ?>">Click this!</a>


Use this one.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:13 PM   #3
Ian.H [dS]
 
Ian.H [dS]'s Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

On Tue, 19 Aug 2003 02:16:13 -0600 in
<message-id:190820030216135042%unix_core@linuxmail.org>
E-Star <unix_core@linuxmail.org> wrote:

> In article <3f41d39e$0$32454$edfadb0f@dread16.news.tele.dk> , The
> Plankmeister <plankmeister_NO_@_SPAM_hotmail.com> wrote:
>
> > <a href="<?php echo $some_url_or_other ?>">Click this!</a>

>
> Use this one.



.... and to explain why to the OP...

<? ?> can be used if shorttags is enabled in php.ini but this isn't
always the case for every server and I suspect becoming less and less
the case as more and more people use XML for various tasks. XML uses
<?xml as it's tag, and causes confusion with PHP, so it's always
advisable (IMO at least) to use the <?php rather than <? (extending to
the echo <?php echo rather than <?= too).


HTH =)



Regards,

Ian

--
Ian.H [Design & Development]
digiServ Network - Web solutions
www.digiserv.net | irc.digiserv.net | forum.digiserv.net
Programming, Web design, development & hosting.
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:13 PM   #4
Jochen Buennagel
 
Jochen Buennagel's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

Ian.H [dS] wrote:

> <? ?> can be used if shorttags is enabled in php.ini but this isn't
> always the case for every server and I suspect becoming less and less
> the case as more and more people use XML for various tasks. XML uses
> <?xml as it's tag, and causes confusion with PHP, so it's always
> advisable (IMO at least) to use the <?php rather than <? (extending to
> the echo <?php echo rather than <?= too).


shorttags off has the advantage that you can use "<?xml" directly in
your files (i.e. without having to "print()" or "echo()" it), but if you
do that, you lose the ability to run your script on a server that has
shorttags on. If you're going to run only on servers who's php.ini you
control, that's no problem, but the default is still shorttags=on, so
that is what most hosters use.

So, if you're coding for the general public, shorttags=on is more
common, but you can't rely on it, so it is safer to use "<?php echo...".
But you can't rely on shorttags=off either, so for xhtml compliant files
you should use <?php echo "<?xml....";?>

Jochen

--
/**
* @author Jochen Buennagel <zang at buennagel dot com>
* @see http://www.sourceforge.net/projects/zang
*/

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:23 PM   #5
DvDmanDT
 
DvDmanDT's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

XHTML doesn't really care which version you use... The absolute best way
anyway seems to be <?PHP echo $url;?> Notice the ;... Doesn't matter though,
just that it seems better as chances are you might feel like extending that
piece of code and forget to att the ; at that point...

--
// DvDmanDT
MSN: dvdmandt@hotmail.com
Mail: dvdmandt@telia.com
"The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> skrev i meddelandet
news:3f41d39e$0$32454$edfadb0f@dread16.news.tele.d k...
> Hi...
>
> I seem to remember reading somewhere about the proper way of doing this

sort
> of thing in the middle of some html, for example:
>
> <a href="<?= $some_url_or_other ?>">Click this!</a>
>
> What is the most proper way of doing such? Would it be to do the full
> monty?:
>
> <a href="<?php echo $some_url_or_other ?>">Click this!</a>
>
> I am writing my output to be xhtml strict compliant, so I guess for
> continuity alone it should be the latter, but are there any specific

reasons
> for using the long-winded way? I'd like to know people's thoughts...
>
> HYCSSLOTS...
>
>
> Plankmeister.
>
>



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:24 PM   #6
R. Rajesh Jeba Anbiah
 
R. Rajesh Jeba Anbiah's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

"The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> wrote in message news:<3f41d39e$0$32454$edfadb0f@dread16.news.tele. dk>...
> Hi...
>
> I seem to remember reading somewhere about the proper way of doing this sort
> of thing in the middle of some html, for example:
>
> <a href="<?= $some_url_or_other ?>">Click this!</a>
>
> What is the most proper way of doing such? Would it be to do the full
> monty?:
>
> <a href="<?php echo $some_url_or_other ?>">Click this!</a>


I prefer short tag <?=$foo?> 'cos it's IMO quite fast. Also, I
hate echo and would prefer to write PHP code without the use of echo.

(Many thanks to Rasmus for fighting on behalf of short tags)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:31 PM   #7
Robert Hennig
 
Robert Hennig's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default <?= $some_var_or_other ?> ... <?php echo $some_var_or_other ?>

Jochen Buennagel wrote:

> Ian.H [dS] wrote:
>
>> <? ?> can be used if shorttags is enabled in php.ini but this isn't
>> always the case for every server and I suspect becoming less and less
>> the case as more and more people use XML for various tasks. XML uses
>> <?xml as it's tag, and causes confusion with PHP, so it's always
>> advisable (IMO at least) to use the <?php rather than <? (extending to
>> the echo <?php echo rather than <?= too).

>
>
> shorttags off has the advantage that you can use "<?xml" directly in
> your files (i.e. without having to "print()" or "echo()" it), but if you
> do that, you lose the ability to run your script on a server that has
> shorttags on. If you're going to run only on servers who's php.ini you
> control, that's no problem, but the default is still shorttags=on, so
> that is what most hosters use.
>
> So, if you're coding for the general public, shorttags=on is more
> common, but you can't rely on it, so it is safer to use "<?php echo...".
> But you can't rely on shorttags=off either, so for xhtml compliant files
> you should use <?php echo "<?xml....";?>
>
> Jochen
>

Or use:
if(ini_get('short_open_tag') == 'on') {
[code to be executed if shorttag is enabled]
}
else {
[code to be excecuted with shorttag disabled]
}

Robert

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Echo getting Parse error Jeffrey Ellis PHP 8 07-01-2007 5:09 PM
echo using bluetooth headset with anycom usb-100 Dietmar Krick Bluetooth Software and Hardware 3 06-17-2007 12:24 PM
echo... Phil Da Lick! Computer Consoles 2 05-30-2007 10:05 PM


Featured Websites




All times are GMT +1. The time now is 12:22 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98