473,789 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple questions (<%=, error reporting)

Hi, I'm a newbie coming from JSP (and also a lifetime of C/C++/Java), and
I was wondering if someone could help me with the following questions.

1. Does PHP have a way to display an expression or variable without
using echo? I'm particularly looking for JSP's <%= %> operator
that will allow me to embed a variable right into HTML.

2. About error reporting, I've found that the default error reporting
level doesn't report undefined variables (these are occuring, for
example, when I misspell a variable name). If I set error_reporting
in php.ini to be E_ALL, undefined variables will be reported, but I
also get a lot of undefined variable errors in HTTP_POST_VARS and the like.
Surely that has to be a happy medium?

Thank you for any help.
Jul 16 '05 #1
3 2052
* di**********@ho tmail.com (Digital Puer):
1. Does PHP have a way to display an expression or variable without
using echo? I'm particularly looking for JSP's <%= %> operator that will
allow me to embed a variable right into HTML.


I think you're looking for <?=$variable? >. Example:

<b>The value is: <i><?=$value? ></i></b>

You can also use this syntax for expressions, e.g.,

<b>The value is: <i><?=($foo+5 )/$bar?></i><b>

HTH,
--
Benjamin D. Esham { http://bdesham.net
bd*****@iname.c om } AIM: bdesham 1 2 8
"...more and more of our imports are coming from
overseas." -- George W. Bush on NPR, 09/26/2000

Jul 16 '05 #2

"Digital Puer" <di**********@h otmail.com> wrote in message
news:80******** *************** ***@posting.goo gle.com...
2. About error reporting, I've found that the default error reporting
level doesn't report undefined variables (these are occuring, for
example, when I misspell a variable name). If I set error_reporting
in php.ini to be E_ALL, undefined variables will be reported, but I
also get a lot of undefined variable errors in HTTP_POST_VARS and the like. Surely that has to be a happy medium?

Thank you for any help.


Try this:

error_reporting (E_ALL & ~E_NOTICE);
Jul 16 '05 #3
Benjamin Esham wrote:
* di**********@ho tmail.com (Digital Puer):
1. Does PHP have a way to display an expression or variable without
using echo? I'm particularly looking for JSP's <%= %> operator that will
allow me to embed a variable right into HTML.


I think you're looking for <?=$variable? >. Example:

<b>The value is: <i><?=$value? ></i></b>

You can also use this syntax for expressions, e.g.,

<b>The value is: <i><?=($foo+5 )/$bar?></i><b>

HTH,


Don't forget to set

short_open_tag = On
asp_tags = On

in php.ini

With short_open_tag off you have to start every piece
of PHP code with <?php

With it on you can start PHP code with <?

If you will be using your scripts on servers you do not
control, it's better to always use <?php as it will
not fail no matter what the settings are in php.ini

The last option allows you to do start php code with
<% instead of <?. I'm not sure if you must use <%php
if you keep short_open_tag off :) Try it!
--
"Yes, I'm positive."
"Are you sure?"
"Help, somebody has stolen one of my electrons!"
Two atoms are talking:
Jul 16 '05 #4

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

Similar topics

31
14351
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? Basically: "Press any key to continue..." I beleive that I am looking for is something along the lines of a....
16
2908
by: Terry | last post by:
Hi, This is a newbie's question. I want to preload 4 images and only when all 4 images has been loaded into browser's cache, I want to start a slideshow() function. If images are not completed loaded into cache, the slideshow doesn't look very nice. I am not sure how/when to call the slideshow() function to make sure it starts after the preload has been completed.
3
1961
by: Jofio | last post by:
My PHP code to read a simple text file is listed below. What could have gone wrong here? When I run it, the browser displays: 'COULD NOT Read' opton of the fread() function. I thought the code was OK. <?php $visitorFile="counter.txt"; $fh=fopen($visitorFile,"r+") or die("could not open."); echo 'Debug 1: opened to read';
8
5279
by: Markus Wildgruber | last post by:
Hi! We want to use XSL-FO in the reporting of our application. Before making the decision we have some questions on that topic: Does anyone have experience with XSL-FO in the .NET environment? Is that a useful technique for professional reporting? Is it technically mature? Does anyone know of a control (WinForms/WebForms) that we can use to show the formatted XSL-FO data?
162
14924
by: techievasant | last post by:
hello everyone, Iam vasant from India.. I have a test+interview on C /C++ in the coming month so plz help me by giving some resources of FAQS, interview questions, tracky questions, multiple choice questions.etc.. I'll be indebted to everyone.. Thanks in advance.. regards vasant shetty Bangalore
5
4517
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by including the -q64 option in xlC compiler. And we are able to link all these libraries to one of the main applications and generate an executable. SKLoader. But, when we try to run this main executable, we are getting the following errors:
2
4840
by: DeanL | last post by:
Hi Guys, I've been trawling through this group for an answer to this but can't find one that works. I have an Access 97 db sitting on a Novell server that is accessed via a front end with linked tables. There are several users that need access to this db but some get the "Couldn't us <filenameFile already in use" error. Every user has the same level of access rights to the server and their accounts are all identical but some still...
7
1697
by: bvdp | last post by:
Okay guys. I have the _ast based safe eval installed and working in my program. It appears to be working just fine. Thanks for the help. Now, a few more questions: 1. I see that _ast is a 2.5 module?? So, for folks using my code with <2.5 I could do something like this: # I've got some imports here to look after the error() and warning() funcs ....
0
2943
by: reema | last post by:
EJB Interview Questions http://interviewdoor.com/technical/EJB-Interview-Questions.htm CSS Interview Questions http://interviewdoor.com/technical/CSS-Interview-Questions.htm C Interview Questions http://interviewdoor.com/technical/C-Interview-Questions.htm C# Interview Questions http://interviewdoor.com/technical/C-sharp-Interview-Questions.htm C++ Interview Questions http://interviewdoor.com/technical/C++-Interview-Questions.htm
0
9511
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,...
0
10200
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
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
9984
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
7529
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4093
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
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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.