PHP double quotes inside double quotes

Discussion in 'Computer Support' started by MSB, Oct 20, 2006.

  1. MSB

    MSB Guest

    I am trying to figure out how to do double quotes inside double quotes

    $newcode = str_replace("<a", "<a target=_blank", $newcode);

    $newcode = str_replace("<a", "<a target="_blank"", $newcode);

    the code works as is in the first example...but it screws up my validation
    when it is parsed
    MSB, Oct 20, 2006
    #1
    1. Advertising

  2. MSB wrote:

    > I am trying to figure out how to do double quotes inside double quotes
    >
    > $newcode = str_replace("<a", "<a target=_blank", $newcode);


    $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode);

    --
    -bts
    -Motorcycles defy gravity; cars just suck
    Beauregard T. Shagnasty, Oct 20, 2006
    #2
    1. Advertising

  3. MSB

    MSB Guest

    Thanks,,, I think I had already found the answer.

    Can't it also be written as such:

    $newcode = str_replace("<a", "<a target='_blank'", $newcode);

    because XHTML does not distinguish between single and double quotes and PHP
    takes single quotes as a literal.

    ??

    "Beauregard T. Shagnasty" <> wrote in message
    news:UcVZg.86715$...
    > MSB wrote:
    >
    >> I am trying to figure out how to do double quotes inside double quotes
    >>
    >> $newcode = str_replace("<a", "<a target=_blank", $newcode);

    >
    > $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode);
    >
    > --
    > -bts
    > -Motorcycles defy gravity; cars just suck
    MSB, Oct 20, 2006
    #3
  4. MSB wrote:

    > "Beauregard T. Shagnasty" <> wrote:
    >> MSB wrote:
    >>
    >>> I am trying to figure out how to do double quotes inside double quotes
    >>>
    >>> $newcode = str_replace("<a", "<a target=_blank", $newcode);

    >>
    >> $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode);

    >
    > Thanks,,, I think I had already found the answer.
    >
    > Can't it also be written as such:
    >
    > $newcode = str_replace("<a", "<a target='_blank'", $newcode);


    Yes it can, but I thought you were doing a string replace (str_replace)
    where you would be wanting to find the word _blank surrounded by double
    quotes. It appeared you wanted to remove [ target="_blank" ] from links.

    > because XHTML does not distinguish between single and double quotes and PHP
    > takes single quotes as a literal.


    (X)HTML probably doesn't care, but that wasn't your question.

    --
    -bts
    -Motorcycles defy gravity; cars just suck
    Beauregard T. Shagnasty, Oct 20, 2006
    #4
  5. MSB

    MSB Guest

    not remove it from links...add it to them so they open a new page

    But thanks anyway.. It worked..


    "Beauregard T. Shagnasty" <> wrote in message
    news:bRXZg.314780$...
    > MSB wrote:
    >
    >> "Beauregard T. Shagnasty" <> wrote:
    >>> MSB wrote:
    >>>
    >>>> I am trying to figure out how to do double quotes inside double quotes
    >>>>
    >>>> $newcode = str_replace("<a", "<a target=_blank", $newcode);
    >>>
    >>> $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode);

    >>
    >> Thanks,,, I think I had already found the answer.
    >>
    >> Can't it also be written as such:
    >>
    >> $newcode = str_replace("<a", "<a target='_blank'", $newcode);

    >
    > Yes it can, but I thought you were doing a string replace (str_replace)
    > where you would be wanting to find the word _blank surrounded by double
    > quotes. It appeared you wanted to remove [ target="_blank" ] from links.
    >
    >> because XHTML does not distinguish between single and double quotes and
    >> PHP
    >> takes single quotes as a literal.

    >
    > (X)HTML probably doesn't care, but that wasn't your question.
    >
    > --
    > -bts
    > -Motorcycles defy gravity; cars just suck
    MSB, Oct 20, 2006
    #5
  6. MSB wrote:

    > not remove it from links...add it to them so they open a new page


    Oh yeah. I was forgetting the order of the params. But why would you
    want to foist new windows on your visitors? Many people do not like
    them.

    Those who run with maximized windows will not notice they've got a new
    one on top, and the Back button is broken. What do they do? Go back to
    google and find some other site. Sometime later, when they are finished
    surfing, they will find your original window...

    > But thanks anyway.. It worked..


    Well, that be good. <g>

    --
    -bts
    -Motorcycles defy gravity; cars just suck
    Beauregard T. Shagnasty, Oct 20, 2006
    #6
  7. MSB

    MSB Guest

    "Beauregard T. Shagnasty" <> wrote in message
    news:gQ3_g.317201$...
    > MSB wrote:
    >
    >> not remove it from links...add it to them so they open a new page

    >
    > Oh yeah. I was forgetting the order of the params. But why would you
    > want to foist new windows on your visitors? Many people do not like
    > them.
    >
    > Those who run with maximized windows will not notice they've got a new
    > one on top, and the Back button is broken. What do they do? Go back to
    > google and find some other site. Sometime later, when they are finished
    > surfing, they will find your original window...
    >
    >> But thanks anyway.. It worked..

    >
    > Well, that be good. <g>
    >
    > --
    > -bts
    > -Motorcycles defy gravity; cars just suck


    I just bought a new script for movie listings. It was not made specifically
    for Joomla. I set it up as a standalone to test out and it works great, but
    I wanted to integrate it into my Joomla site. I was not happy with using
    the Wrapper, so I decided to make it into a Component.

    Of course I had no idea how to write a Joomla Component, but I found a few
    tutorials and was able to build it. It is extremely simple. It has no
    backend controls (didn't need them), just the 3 files of the original script
    in the frontend (movies.php, results.php and styles.css) and the necessary
    ..xml and install/uninstall files. The installation was successful and
    movies.php shows up when I connect to the component.

    However, the problem comes when I try to call the results.php. It looks for
    it in the root joomla folder and naturally does not find it (all files are
    in the com_movies folder). If I try to hardcode in the path, I get the
    direct access is denied message. If I take that bit out, it opens the page
    by itself (not as part of my site).

    Here is the code for movies.php that calls results.php:


    Code:
    <form action="results.php" name="search"> Zipcode
    <input type="text" name="zipcode" value="<?php echo $zipcode; ?>" />
    <input type="submit" value="Go" /> </form>

    I am sure there is something I am missing. Any help would be greatly
    appreciated.
    MSB, Oct 21, 2006
    #7
  8. MSB

    MSB Guest

    "MSB" <> wrote in message
    news:74f1f$45398298$d8600654$...
    >
    > "Beauregard T. Shagnasty" <> wrote in message
    > news:gQ3_g.317201$...
    >> MSB wrote:
    >>
    >>> not remove it from links...add it to them so they open a new page

    >>
    >> Oh yeah. I was forgetting the order of the params. But why would you
    >> want to foist new windows on your visitors? Many people do not like
    >> them.
    >>
    >> Those who run with maximized windows will not notice they've got a new
    >> one on top, and the Back button is broken. What do they do? Go back to
    >> google and find some other site. Sometime later, when they are finished
    >> surfing, they will find your original window...
    >>
    >>> But thanks anyway.. It worked..

    >>
    >> Well, that be good. <g>
    >>
    >> --
    >> -bts
    >> -Motorcycles defy gravity; cars just suck

    >
    > I just bought a new script for movie listings. It was not made
    > specifically for Joomla. I set it up as a standalone to test out and it
    > works great, but I wanted to integrate it into my Joomla site. I was not
    > happy with using the Wrapper, so I decided to make it into a Component.
    >
    > Of course I had no idea how to write a Joomla Component, but I found a few
    > tutorials and was able to build it. It is extremely simple. It has no
    > backend controls (didn't need them), just the 3 files of the original
    > script in the frontend (movies.php, results.php and styles.css) and the
    > necessary .xml and install/uninstall files. The installation was
    > successful and movies.php shows up when I connect to the component.
    >
    > However, the problem comes when I try to call the results.php. It looks
    > for it in the root joomla folder and naturally does not find it (all files
    > are in the com_movies folder). If I try to hardcode in the path, I get
    > the direct access is denied message. If I take that bit out, it opens the
    > page by itself (not as part of my site).
    >
    > Here is the code for movies.php that calls results.php:
    >
    >
    > Code:
    > <form action="results.php" name="search"> Zipcode <input
    > type="text" name="zipcode" value="<?php echo $zipcode; ?>" /> <input
    > type="submit" value="Go" /> </form>
    >
    > I am sure there is something I am missing. Any help would be greatly
    > appreciated.
    >


    you can see it work as a standalone here:
    http://www.metrojackson.net/movies/
    MSB, Oct 21, 2006
    #8
  9. MSB

    MSB Guest

    "Beauregard T. Shagnasty" <> wrote in message
    news:gQ3_g.317201$...
    > MSB wrote:
    >
    >> not remove it from links...add it to them so they open a new page

    >
    > Oh yeah. I was forgetting the order of the params. But why would you
    > want to foist new windows on your visitors? Many people do not like
    > them.
    >
    > Those who run with maximized windows will not notice they've got a new
    > one on top, and the Back button is broken. What do they do? Go back to
    > google and find some other site. Sometime later, when they are finished
    > surfing, they will find your original window...
    >
    >> But thanks anyway.. It worked..

    >
    > Well, that be good. <g>
    >
    > --
    > -bts
    > -Motorcycles defy gravity; cars just suck


    If the information was hosted in my database on my site, then obviusly I
    would not open a new window

    I understand what you are saying, but it is unavoidable

    better to open a new window and have them still be on my site than to
    completely send them off of my site
    MSB, Oct 21, 2006
    #9
  10. MSB wrote:

    > "Beauregard T. Shagnasty" <> wrote:
    >> Those who run with maximized windows will not notice they've got a new
    >> one on top, and the Back button is broken. What do they do? Go back to
    >> google and find some other site. Sometime later, when they are finished
    >> surfing, they will find your original window...

    >
    > If the information was hosted in my database on my site, then obviusly I
    > would not open a new window
    >
    > I understand what you are saying, but it is unavoidable
    >
    > better to open a new window and have them still be on my site than to
    > completely send them off of my site


    I mark external links on my sites with an icon to indicate it goes
    off-site, and I use a title attribute to show it as well.

    <a href="http://example.com/">http://example.com/ <img
    src="../images/offsite.gif" alt="↗" title="External Site:
    Right-Click and Open in New Window" width="14" height="11" /></a>

    This is the image:
    http://k75s.home.att.net/show/offsite.gif

    wikipedia.com, as another example, marks all their external links with a
    similar graphic. You can nick mine, or theirs, if you wish. Note that
    the alt="↗" is an arrow, for those who may have images turned
    off.

    This way the visitors make the conscious choice to open a new window (or
    tab) and when the back button doesn't work, they know why. If they just
    click the link, my site is still in the history of the back button.

    I looked at your theater page from your other post. Works fast. Clicking
    a movie title opens a new window, and when my browser was maximized,
    there is no real way to be sure a newbie knows this is completely
    covering your page. When she finds the Back button is grayed out, she
    would then click her search engine bookmark, and find another movie
    site. They are reluctant to close the browser window because they are
    intimidated by the fact that if the browser window goes away, they will
    have to "redial the internet". So they go surf elsewhere.

    I've watched over the shoulder of the .. um .. less experienced .. and
    have seen them do this, numerous times. Sorry for harping about it, but
    I feel it is important. :)

    Oh, one point about the code on the movie page: there is an HTML
    comment at the beginning, above the DOCTYPE. This will throw Internet
    Exploder into Quirks Mode. You should remove whatever is placing the
    comment...

    --
    -bts
    -Motorcycles defy gravity; cars just suck
    Beauregard T. Shagnasty, Oct 21, 2006
    #10
  11. MSB

    MSB Guest

    "Beauregard T. Shagnasty" <> wrote in message
    news:6gg_g.321104$...
    > MSB wrote:
    >
    >> "Beauregard T. Shagnasty" <> wrote:
    >>> Those who run with maximized windows will not notice they've got a new
    >>> one on top, and the Back button is broken. What do they do? Go back to
    >>> google and find some other site. Sometime later, when they are finished
    >>> surfing, they will find your original window...

    >>
    >> If the information was hosted in my database on my site, then obviusly I
    >> would not open a new window
    >>
    >> I understand what you are saying, but it is unavoidable
    >>
    >> better to open a new window and have them still be on my site than to
    >> completely send them off of my site

    >
    > I mark external links on my sites with an icon to indicate it goes
    > off-site, and I use a title attribute to show it as well.
    >
    > <a href="http://example.com/">http://example.com/ <img
    > src="../images/offsite.gif" alt="↗" title="External Site:
    > Right-Click and Open in New Window" width="14" height="11" /></a>
    >
    > This is the image:
    > http://k75s.home.att.net/show/offsite.gif
    >
    > wikipedia.com, as another example, marks all their external links with a
    > similar graphic. You can nick mine, or theirs, if you wish. Note that
    > the alt="↗" is an arrow, for those who may have images turned
    > off.
    >
    > This way the visitors make the conscious choice to open a new window (or
    > tab) and when the back button doesn't work, they know why. If they just
    > click the link, my site is still in the history of the back button.
    >
    > I looked at your theater page from your other post. Works fast. Clicking
    > a movie title opens a new window, and when my browser was maximized,
    > there is no real way to be sure a newbie knows this is completely
    > covering your page. When she finds the Back button is grayed out, she
    > would then click her search engine bookmark, and find another movie
    > site. They are reluctant to close the browser window because they are
    > intimidated by the fact that if the browser window goes away, they will
    > have to "redial the internet". So they go surf elsewhere.
    >
    > I've watched over the shoulder of the .. um .. less experienced .. and
    > have seen them do this, numerous times. Sorry for harping about it, but
    > I feel it is important. :)
    >
    > Oh, one point about the code on the movie page: there is an HTML
    > comment at the beginning, above the DOCTYPE. This will throw Internet
    > Exploder into Quirks Mode. You should remove whatever is placing the
    > comment...
    >
    > --
    > -bts
    > -Motorcycles defy gravity; cars just suck


    Got a link to ur site? I would like to check it out.
    MSB, Oct 21, 2006
    #11
  12. Beauregard T. Shagnasty, Oct 21, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tom Accuosti
    Replies:
    3
    Views:
    484
    Travis Evans
    Sep 27, 2004
  2. raviraj joshi
    Replies:
    0
    Views:
    641
    raviraj joshi
    Jul 4, 2009
  3. EVS
    Replies:
    0
    Views:
    1,877
  4. infocus
    Replies:
    0
    Views:
    886
    infocus
    Jul 19, 2010
  5. EVS
    Replies:
    0
    Views:
    1,734
Loading...

Share This Page