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

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 2034
* di**********@hotmail.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.com } 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**********@hotmail.com> wrote in message
news:80**************************@posting.google.c om...
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**********@hotmail.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
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? ...
16
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...
3
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...
8
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?...
162
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...
5
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...
2
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...
7
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...
0
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.