simple questions (<%=, error reporting)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Digital Puer

    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.
  • Benjamin Esham

    #2
    Re: simple questions (&lt;%=, error reporting)

    * digital_puer@ho tmail.com (Digital Puer):
    [color=blue]
    > 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.[/color]

    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
    bdesham@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

    Comment

    • Leslie Hoare

      #3
      Re: simple questions (&lt;%=, error reporting)


      "Digital Puer" <digital_puer@h otmail.com> wrote in message
      news:80678590.0 309011604.5f717 289@posting.goo gle.com...
      [color=blue]
      > 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[/color]
      like.[color=blue]
      > Surely that has to be a happy medium?
      >
      > Thank you for any help.[/color]

      Try this:

      error_reporting (E_ALL & ~E_NOTICE);


      Comment

      • Pedro

        #4
        Re: simple questions (&lt;%=, error reporting)

        Benjamin Esham wrote:[color=blue]
        >* digital_puer@ho tmail.com (Digital Puer):
        >[color=green]
        >> 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.[/color]
        >
        >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,[/color]

        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:

        Comment

        Working...