473,625 Members | 2,717 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2313
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*******@attgl obal.net
=============== ===

Jun 2 '08 #2
On May 7, 4:20 am, Pakku <pa...@soccerma il.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...@soccerma il.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?myse lf, and, as expected, it gave me a parse
error (unexpected '='), while doing <?=$var?inste ad 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******@NOSPAM betadome.com
(remove NOSPAM to contact me directly)
Jun 2 '08 #4
On May 7, 7:19 am, Kim André Akerĝ <kiman...@NOSPA Mbetadome.com>
wrote:
Gordon wrote:
On May 7, 4:20 am, Pakku <pa...@soccerma il.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?myse lf, and, as expected, it gave me a parse
error (unexpected '='), while doing <?=$var?inste ad 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...@NOSPAM betadome.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
3552
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 to me. I recently created a BBS (Bulletin Board Service) on my website where I allow people to post messages via a form. It just occurred to me that conceivably they could embed php code in their message trying to 'hack' my site. So I
2
2109
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 is my code that generates the string : function InvokeURL(url_to_forward_to) { try {
2
1568
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 Opera both complain about my use of &var=value pairs in the generated URL. Below is my code that generates the string, and is part of an embedded HTML page (generated on the fly by a PHP script): function InvokeURL(url_to_forward_to) {
10
4447
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 Enterplise Linux 3 ES, and applied FixPack fp5_mi00069.tar to it. After creating an instance, starting the database, creating a database, and entering the table definitions, all of which seems to work OK, I entered a tiny 8-row table and can do...
6
1981
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 feedback as well as some good book suggestions. Thanks, Shalini
35
9955
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 the program. Since fgets() doesn't return the number of characters read it is pretty tough to handle the embedded nulls once they are in the buffer. So two questions: 1. Why did the folks who wrote fgets() have a successful
59
7152
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. I think I could possibly get what I want by launching a captive copy of postmaster with appropriate args but it seems conceptually cleaner to not have a seperate process at all. Has anyone tried to do anything like this? I've looked at sqlite...
2
8159
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() { var a = document.getElementById("obj1"); var obj = document.createElement("object"); obj.data = "dayenu.mid";
20
2025
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: memset(data,-1,sizeof data)
0
8189
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8354
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6116
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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 we have to send another system
1
1802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1499
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.