473,221 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

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 1894
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
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
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
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
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
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
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
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
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
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
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.