473,498 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP Output Help

rik
I was flicking through a PHP book (one of the teach in 24 hour ones)
and I came across something I had never seen before in PHP. It was a
method of printing out without using the print method, it was something
like :

<?= $myVar; ?>

Is this an out dated method? Is it compatible with all versions of PHP
(since implementation at least)?

Rick
www.e-connected.com
Aug 9 '05 #1
16 1912
On 9 Aug 2005 07:40:53 -0700, "rik" <ri*******@e-connected.com> wrote:
I was flicking through a PHP book (one of the teach in 24 hour ones)
and I came across something I had never seen before in PHP. It was a
method of printing out without using the print method, it was something
like :

<?= $myVar; ?>

Is this an out dated method?
Well, it's deprecated, as it requires short_open_tags to be enabled.

You might have thought that <?php=$myVar?> would be the long tags equivalent,
but it doesn't work.
Is it compatible with all versions of PHP
(since implementation at least)?


As far as I know - certainly valid a long way back.

I believe it's partly there to make ASP programmers more comfortable when
migrating since ASP has <%=variable%>.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Aug 9 '05 #2
It is the "shortcut syntax" for echo: see the manual at
http://us3.php.net/manual/en/function.echo.php
As others have noted, it's deprecated.

Aug 9 '05 #3
Andy Hassall wrote:
On 9 Aug 2005 07:40:53 -0700, "rik" <ri*******@e-connected.com> wrote:
I was flicking through a PHP book (one of the teach in 24 hour ones)
and I came across something I had never seen before in PHP. It was a
method of printing out without using the print method, it was something
like :

<?= $myVar; ?>

Is this an out dated method?


Well, it's deprecated, as it requires short_open_tags to be enabled.


I dont' think, it's deprecated.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Aug 9 '05 #4

R. Rajesh Jeba Anbiah wrote:
Andy Hassall wrote:
Well, it's deprecated, as it requires short_open_tags to be enabled.


I dont' think, it's deprecated.


Well you are right in that 'deprecated' is not used to describe short
tags in the documentation. They are instead described as something to
avoid since they will not validate in XHTML or XML and are no longer
supported in all PHP implementations. By inference, whatever value they
may have had back in the day is no longer sufficient to justify their
use in new code. This is the operative definition of 'to deprecate' (in
this context).

Since the shortcut form of "echo" requires short tags, it too is
something we should leave behind as PHP evolves.

Aug 9 '05 #5
Will Woodhull wrote:
R. Rajesh Jeba Anbiah wrote:

Andy Hassall wrote:

Well, it's deprecated, as it requires short_open_tags to be enabled.

I dont' think, it's deprecated.


Well you are right in that 'deprecated' is not used to describe short
tags in the documentation. They are instead described as something to
avoid since they will not validate in XHTML or XML and are no longer
supported in all PHP implementations. By inference, whatever value they
may have had back in the day is no longer sufficient to justify their
use in new code. This is the operative definition of 'to deprecate' (in
this context).

Since the shortcut form of "echo" requires short tags, it too is
something we should leave behind as PHP evolves.

Awwwww crap! I hate this deprecation merry-go-round.

I've got short tags all over my scripts, as I started doing so in the
beginning. It looks a lot nicer and uses a lot less characters (looks
less busy). It's embedded into my personal style now (<? ?> and <?= ?>).

I suppose a quick and easy search and replace could fix it all up if I
ever have the need.

XML? What's XML? ô¿Ô¬

I haven't even begun to explore xml. My sites are all Php, MySQL, HTML,
CSS and JavaScript (and DHTML). It looks like I'll have to delve into it
eventually.

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Aug 9 '05 #6
Why on earth would you want to run a PHP script through a XML
validator? If you ask me, being compliant with some standard just
because the standard is there is stupid.

Aug 10 '05 #7
On 2005-08-09 19-34-48 Will Woodhull <wi**@thornhenge.org> wrote:
They are instead described as something to
avoid since they will not validate in XHTML or XML


tbh, I don't care whether my PHP files validate against XHTML or XML as
long as their output does.

Regards,
Simon
--
Simon Stienen <http://slashlife.org/>
"What you do in this world is a matter of no consequence,
The question is, what can you make people believe that you have done."
/Sherlock Holmes in A Study in Scarlet by Sir Arthur Conan Doyle/
Aug 10 '05 #8
*** Will Woodhull wrote/escribió (9 Aug 2005 10:34:48 -0700):
Well you are right in that 'deprecated' is not used to describe short
tags in the documentation. They are instead described as something to
avoid since they will not validate in XHTML or XML


Which is obviously right: PHP is not XHTML or XML.

--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Aug 10 '05 #9
rik
I suppose the difference between ASP and PHP is that echo $var; is much
shorter than response.write var so there is less need to have a
shorthnd version of it.

Rick
www.e-connected.com

Aug 10 '05 #10
rik wrote:
I suppose the difference between ASP and PHP is that echo $var; is much
shorter than response.write var so there is less need to have a
shorthnd version of it.


ASP too has short hand version <%= foo %>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Aug 10 '05 #11
Chuck Anderson wrote:
<snip>
Awwwww crap! I hate this deprecation merry-go-round.

I've got short tags all over my scripts, as I started doing so in the
beginning. It looks a lot nicer and uses a lot less characters (looks
less busy). It's embedded into my personal style now (<? ?> and <?= ?>).

I suppose a quick and easy search and replace could fix it all up if I
ever have the need.

XML? What's XML? ô¿Ô¬


Probably this might help a bit
<news:11**********************@z14g2000cwz.googleg roups.com> (
http://groups.google.com/group/comp....5600a4b7b4568a )

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

Aug 10 '05 #12
On 9 Aug 2005 10:34:48 -0700, "Will Woodhull" <wi**@thornhenge.org> wrote:
They are instead described as something to
avoid since they will not validate in XHTML or XML


I don't see that as the reason. It's more because having a literal XML prolog
at the start of the file gets misinterpreted as PHP.

<?xml version="1.0" ...
^^
PHP sees this as start of PHP. So you have to faff around with:

<?php print "<?xml ..."

You wouldn't run PHP source through an XML validator in the first place.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Aug 10 '05 #13
Andy Hassall wrote:
On 9 Aug 2005 10:34:48 -0700, "Will Woodhull" <wi**@thornhenge.org> wrote:

<?xml version="1.0" ...
^^
PHP sees this as start of PHP.

Good point.

You wouldn't run PHP source through an XML validator in the first place.

I haven't done anything with PHP and XML as yet.

It is easier to validate a complex XHTML template with embedded PHP as
a .html page-- so there are times when it makes sense to run PHP source
through a validator. I expect that when I start working with AJAX kinds
of things, passing PHP source through the XML validator will be pretty
common.

Aug 10 '05 #14
On 10 Aug 2005 15:04:38 -0700, "Will Woodhull" <wi**@thornhenge.org> wrote:
Andy Hassall wrote:
You wouldn't run PHP source through an XML validator in the first place.


I haven't done anything with PHP and XML as yet.

It is easier to validate a complex XHTML template with embedded PHP as
a .html page-- so there are times when it makes sense to run PHP source
through a validator. I expect that when I start working with AJAX kinds
of things, passing PHP source through the XML validator will be pretty
common.


Hm, I still don't see why you'd pass the SOURCE through an XML validator. You
pass the OUTPUT through a validator; sure.

Surely you're not going to get very far trying to write XML-validated PHP
source code; kinda rules out using "&&" ... unless you start jumping through
hoops with CDATA or something. Then again I don't know enough about how an XML
validator would react to the contents of a <?php ?> processing instruction.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Aug 10 '05 #15
Andy Hassall wrote:
On 10 Aug 2005 15:04:38 -0700, Will Woodhull wrote:
Andy Hassall wrote:
You wouldn't run PHP source through an XML validator in the first
place.
It is easier to validate a complex XHTML template with embedded PHP as
a .html page-- so there are times when it makes sense to run PHP source
through a validator.
Hm, I still don't see why you'd pass the SOURCE through an XML validator.
You pass the OUTPUT through a validator; sure.

Surely you're not going to get very far trying to write XML-validated PHP
source code; kinda rules out using "&&" ... unless you start jumping through
hoops with CDATA or something. Then again I don't know enough about how an
XML validator would react to the contents of a <?php ?> processing
instruction.


As I said earlier, I don't know about XML validation-- I'll see about
that when I get there.

With XHTML, so far my experience has been that code within the <?php
.... ?> tag is ignored by the validators. Just to be clear, I'm talking
about validating stuff like

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title><?php echo $_SESSION[spreadsheet][title] ?></title>
<script type="text/javascript">
<!--
<?php
echo <<<EOHere
// functions providing spreadsheet capabilities and
EOHere;
// load initial spreadsheet values
echo $_SESSION[spreadsheet][javascriptVariables];
?>
// -->
</script>
</head>
<body onload="LoadDataToSpreadsheet()">
<div id="spreadsheet">
<!-- a complicated spreadsheet-like structure
with lots of "cells" -->
</div>
<form>
<!-- front end providing spreadsheet interface -->
</form>
</body>
</html>

A template like this can be complex enough that it makes sense to
validate it independently of the stuff that the PHP script will add.

Aug 11 '05 #16
Andy Hassall wrote:
Then again I don't know enough about how an XML validator would react
to the contents of a <?php ?> processing instruction.


It wouldn't react at all, because Processing Instructions are
opaque to XML - they're passed to the application as they are.
Anything goes, up till PIClose, '?>' ('>' in HTML), whether or
not PHP would interpret that PIC as a closing PHP tag.

--
Jock
Aug 11 '05 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2689
by: Richard Tierney | last post by:
To create help output (the response to "myprog --help", for example) I currently create a big .h file, which includes a single string, such as: static char *help_text = "\ myprog: my program\n\...
3
1729
by: danmc91 | last post by:
Hi, I'm just getting going with xml and xslt. I'm trying to write what are essentially man pages and I need 3 output formats. 1) nroff -man format for real man pages 2) html for an online...
2
1335
by: Welman Jordan | last post by:
Hello, I met with a tough problem when making my pages. Please help. To make the problem short, i write down what i want here first, and then explain my situation in details. How can I...
0
1502
by: F.C. | last post by:
Hello, :) I'm currently writing a frontend for a console application using VB .net. I'm using the traditional Process creation to launch it and redirect input and output to my windows...
3
1276
by: sp | last post by:
hai i have got 1. an xml file 2. an xsl file and my xsl file filters the xml based on attribute value and the output i receive is in the ordinary format
0
2045
by: newbie | last post by:
i'm a newbie of c language. can anyone help me to implement the code so that I can get the ciphertext from the output. thanks. #ifndef _3DES_H #define _3DES_H #ifndef uint8 #define uint8 ...
1
12282
by: John Bailo | last post by:
This is a my solution to getting an Output parameter from a SqlDataSource. I have seen a few scant articles but none of them take it all the way to a solution. Hopefully this will help some...
1
3573
by: yohan610 | last post by:
i have to read the binary data of a file, then encrypt them according to a supplied algorithm...and then the obtained output has to be written to an output file...everything works ok, and there are...
14
12769
by: =?Utf-8?B?R2lkaQ==?= | last post by:
Hi, In my windows applicationm, i need to excute a batch file. this batch file throws some text and questions to the screen, i need to catch the standard Output, check if it's a question, in...
1
1274
by: LittlBUGer | last post by:
Hello. First of all I'm programming in VB.NET/ASP.NET doing a page for a website. Now, to my question.... I have a simple array of integer numbers (15 characters in length) which can hold up to...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.