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. Advertisements

  2. $newcode = str_replace("<a", "<a target=\"_blank\"", $newcode);
    Beauregard T. Shagnasty, Oct 20, 2006
    1. Advertisements

  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.

    MSB, Oct 20, 2006
  4. 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.
    (X)HTML probably doesn't care, but that wasn't your question.
    Beauregard T. Shagnasty, Oct 20, 2006
  5. MSB

    MSB Guest

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

    But thanks anyway.. It worked..

    MSB, Oct 20, 2006
  6. 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

    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...
    Well, that be good. <g>
    Beauregard T. Shagnasty, Oct 20, 2006
  7. MSB

    MSB Guest

    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:

    <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
    MSB, Oct 21, 2006
  8. MSB

    MSB Guest

    you can see it work as a standalone here:
    MSB, Oct 21, 2006
  9. MSB

    MSB Guest

    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
  10. 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=""> <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:, 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

    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
    Beauregard T. Shagnasty, Oct 21, 2006
  11. MSB

    MSB Guest

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.