473,396 Members | 1,726 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,396 software developers and data experts.

embedded variable in HTML

On this site http://www.onlamp.com/pub/a/php/2001...undations.html
I discovered that I could embed php variables in html using this
notation

The variable $var has a value of: <?=$var?><br />

But I think this doesn't work with php version 5 and above. I
searched and searched on the web to confirm this but it was rather
difficult (I can't, for example, search on the string "<?=")

I did see one reference which discouraged the use of this approach
because of some XML compliance issue.

Would appreciate hearing from you all about this, I found it much
easier to do this than reams of echo statements to generate html.
Jun 2 '08 #1
4 2301
Pakku wrote:
On this site http://www.onlamp.com/pub/a/php/2001...undations.html
I discovered that I could embed php variables in html using this
notation

The variable $var has a value of: <?=$var?><br />

But I think this doesn't work with php version 5 and above. I
searched and searched on the web to confirm this but it was rather
difficult (I can't, for example, search on the string "<?=")

I did see one reference which discouraged the use of this approach
because of some XML compliance issue.

Would appreciate hearing from you all about this, I found it much
easier to do this than reams of echo statements to generate html.
This hasn't changed with PHP releases. Rather, it means short_open_tag
is on in the php.ini file. It's not a good idea to have it on because
the <? tag is used for xml. Don't count on it being available - few
hosts have it, and many turn it off on upgrading.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 2 '08 #2
On May 7, 4:20 am, Pakku <pa...@soccermail.comwrote:
On this sitehttp://www.onlamp.com/pub/a/php/2001/05/03/php_foundations.html
I discovered that I could embed php variables in html using this
notation

The variable $var has a value of: <?=$var?><br />

But I think this doesn't work with php version 5 and above. I
searched and searched on the web to confirm this but it was rather
difficult (I can't, for example, search on the string "<?=")

I did see one reference which discouraged the use of this approach
because of some XML compliance issue.

Would appreciate hearing from you all about this, I found it much
easier to do this than reams of echo statements to generate html.
I don't know because I've not tried it, but have you tried <?php=$var?
to see what you get? Just asking out of curiosity, as I tend to just
use Smarty to handle the presentation parts of a web app.
Jun 2 '08 #3
Gordon wrote:
On May 7, 4:20 am, Pakku <pa...@soccermail.comwrote:
On this
sitehttp://www.onlamp.com/pub/a/php/2001/05/03/php_foundations.html
I discovered that I could embed php variables in html using this
notation

The variable $var has a value of: <?=$var?><br />

But I think this doesn't work with php version 5 and above. I
searched and searched on the web to confirm this but it was rather
difficult (I can't, for example, search on the string "<?=")

I did see one reference which discouraged the use of this approach
because of some XML compliance issue.

Would appreciate hearing from you all about this, I found it much
easier to do this than reams of echo statements to generate html.

I don't know because I've not tried it, but have you tried <?php=$var?
to see what you get? Just asking out of curiosity, as I tend to just
use Smarty to handle the presentation parts of a web app.
I just tested <?php=$var?myself, and, as expected, it gave me a parse
error (unexpected '='), while doing <?=$var?instead gave me the
contents of the variable.

As I suspected, it will only work with shorttags enabled.

Without shorttags, you need to do it like this: <?php echo $var; ?>.

--
Kim André Akerĝ
- ki******@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Jun 2 '08 #4
On May 7, 7:19 am, Kim André Akerĝ <kiman...@NOSPAMbetadome.com>
wrote:
Gordon wrote:
On May 7, 4:20 am, Pakku <pa...@soccermail.comwrote:
On this
sitehttp://www.onlamp.com/pub/a/php/2001/05/03/php_foundations.html
I discovered that I could embed php variables in html using this
notation
The variable $var has a value of: <?=$var?><br />
But I think this doesn't work with php version 5 and above. I
searched and searched on the web to confirm this but it was rather
difficult (I can't, for example, search on the string "<?=")
I did see one reference which discouraged the use of this approach
because of some XML compliance issue.
Would appreciate hearing from you all about this, I found it much
easier to do this than reams of echo statements to generate html.
I don't know because I've not tried it, but have you tried <?php=$var?
to see what you get? Just asking out of curiosity, as I tend to just
use Smarty to handle the presentation parts of a web app.

I just tested <?php=$var?myself, and, as expected, it gave me a parse
error (unexpected '='), while doing <?=$var?instead gave me the
contents of the variable.

As I suspected, it will only work with shorttags enabled.

Without shorttags, you need to do it like this: <?php echo $var; ?>.

--
Kim André Akerĝ
- kiman...@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)
Thank you Kim and Jerry! It had to do with shorttags as you pointed
out. I had it enabled at work where I also happen to have php4 and
disabled at home where I have php5. Classic example of mixing up
causality and correlation!

The way Kim recommends will also enables me to dispense with lengthy
echo statements and escaped quotes- I am going to guess it will be XML
compliant too, right?

I don't know about smarty- just halfway thru an introductory php
course at this time.
Jun 2 '08 #5

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

Similar topics

2
by: Aquarius2431 | last post by:
Hi!, I don't think I have posted to this group before. Have been using PHP on my webserver for a few months now and finding that I like it quite a bit. Here is a question that just occurred...
2
by: Rick | last post by:
Hi.. I've got some code I wrote in PHP that will generate a new argument string for the browser, but the xhtml parser in Firefox and Opera both complain about my use of &var=value pairs. Below...
2
by: Rick | last post by:
Hi.. I've got some code I wrote in PHP that will generate an HTML page with embedded javascript which in turn creates a new argument string for the browser, but the xhtml parser in Firefox and...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
6
by: Shalini | last post by:
Hi, Iam looking for some books which deal with Embedded software as well as C programming. I was suggested An Embedded software primer - David E Simon by a friend. Would like to have your...
35
by: David Mathog | last post by:
Every so often one of my fgets() based programs encounters an input file containing embedded nulls. fgets is happy to read these but the embedded nulls subsequently cause problems elsewhere in...
59
by: Jeff Bowden | last post by:
For ease of configuration and other reasons, I would like for my single-user GUI app to be able to use postgresql in-process as a library accessing a database created in the users home directory. ...
2
by: Owen.Leibman | last post by:
Here is a complete web page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <html> <head> <title>Javascript Embed and onunload</title> <script type="text/javascript"> function useplayer() {...
20
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
There are a few guarantees I exploit in the C Standard. For instance, I might write (unsigned)-1 to get the maximum value for an unsigned integer. Also, I might rely on things such as: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.