SitePoint Sponsor

User Tag List

Results 1 to 14 of 14

Thread: & in links

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    & in links

    Hi,
    I have made many pages in PHP for my website.
    Now it uses alot of GET so I have alot of links that is:
    mysite.com/index.php?a=a&b=b&c=c

    Now there is a problem of W3C validation.
    It says to have mysite.com/index.php?a=a&b=b&c=c

    Every content thats ehoed on my site is first taken into ob_start("myoutput_buffer");

    So is there any Regexp that can be used to replace the a=a&b=b&c=c with a=a&b=b&c=c.

    P.S: I had just given an e.g. my links involve a lot of Dynamic GET Parameters which will take me moths to change manually.

  2. #2
    SitePoint Addict
    Join Date
    Aug 2007
    Location
    GR
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mod_rewrite Apache, cleaner URLs

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there no PHP way.
    I dont want to get into Apache

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mod_rewrite has nothing to do with the posters problem.

    You should encode URL's as HTML-entities -- just like any other content in your page. You can use a tool such as htmltidy to fix your malformed HTML. There's a PHP native extension, which gives you access to tidy, or you could use the standalone tool.

  6. #6
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But arent there ways to use some regexps and clean the output bufffer HTML to W3C valid HTML

  7. #7
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by helpmeinphp View Post
    But arent there ways to use some regexps and clean the output bufffer HTML to W3C valid HTML
    Regular expressions aren't suitable for parsing HTML.

    As I said already, use tidy: http://www.php.net/tidy

  8. #8
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But that is in PHP 4.3.x and i want it for 4.1.0+

  9. #9
    SitePoint Member
    Join Date
    Sep 2006
    Location
    Berlin, Germany
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the htmlentities function.
    htmlentities('mysite.com/index.php?a=a&b=b&c=c')

  10. #10
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by helpmeinphp View Post
    But that is in PHP 4.3.x and i want it for 4.1.0+
    Why is that? 4.1.0 is ancient. As a matter of fact, so is 4.3.x -- It's being discontinued in half a year from now.

  11. #11
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So how does tidy make HTML tidy.
    It will be using RegExp

  12. #12
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by devberlin View Post
    use the htmlentities function.
    htmlentities('mysite.com/index.php?a=a&b=b&c=c')
    this man has the solution to your problem

  13. #13
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Only if there is a single link and that is stored in a Variable.
    I have links in the output buffer in between HTML

  14. #14
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by helpmeinphp View Post
    So how does tidy make HTML tidy.
    It will be using RegExp
    No, it parses the file and builds an internal representation of the document. Then it generates a new HTML document from this representation. It's similar to how a browser interprets HTML.

    You could probably make a solution, using regexp's, but it would be error-prone, because regexp's are not context aware. This is why you generally can't use them to transform a source, which has context (Such as most programming languages, including HTML, has).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •