Escaping

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

    Escaping

    Hello,

    I am trying to output HTML and JavaScript using PHP as the following:

    <span style="float:ri ght;">
    <input type="button" value="Edit" onclick="startE ditCategory('<? php
    echo("{$categor yId}"); ?>', '<?php echo("{$categor yName}"); ?>');" />
    </span>

    The $categoryName variable can contain single and double quotes, so
    how can I escape them?

    Thanks.
  • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

    #2
    Re: Escaping

    Ahmad escribió:
    <span style="float:ri ght;">
    <input type="button" value="Edit" onclick="startE ditCategory('<? php
    echo("{$categor yId}"); ?>', '<?php echo("{$categor yName}"); ?>');" />
    </span>
    >
    The $categoryName variable can contain single and double quotes, so
    how can I escape them?
    With htmlspecialchar s().

    BTW, do you actually know what "{$category Id}" does? You provide an
    array and tell PHP to parse it to find variables and replace them with
    their values. That could make sense with stuff like "Hello, $name\n" but
    not with an array that just contains a variable.



    --
    -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
    -- Mi sitio sobre programación web: http://bits.demogracia.com
    -- Mi web de humor al baño María: http://www.demogracia.com
    --

    Comment

    Working...