Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Code Fixer

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default Code Fixer

    Ok I know javascript is a lot better at this but at the moment my Browsers are being mean to mean and not letting me view JAVASCRIPT... so I gotta use PHP...

    So heres the deal:
    I don't know how todo this because PHP is a little literal. I know this doesn't work but heres what I came up with...
    Codefixer.php:
    HTML Code:
    <form action="fix.php" method="post">
    <textarea cols="50" rows="10" name="Codefixer"></textarea>
    <input type="submit">
    </form>
    Fix.php
    PHP Code:

    <?php
    $Codefixer 
    $_POST["CODEFIXER"];
    $Br "<br>";
    $Correct "<br />";
    if(
    $Br==$Codefixer) {    
        echo 
    "$Correct";
    }
    else
    {
        echo 
    "Code Clear!";
    }
    ?>
    I was hoping so that only the <br> tags get affected, but that doesn't it just checks to see if the value is br... which isn't what I want...

    Thanks for the help!

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <?php 
      echo str_replace('<br>', '<br />', $_POST['CODEFIXER']);
    ?>
    However, I very much doubt whether converting code to IE-unsupported XHTML is "fixing" it. I'd consider it more "breaking." You should probably go the other way:
    Code:
    <?php
      echo str_replace('/>', '>', $_POST['CODEFIXER'];
    ?>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    one small problem... how do you get it so that it goes back into a textarea...

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <textarea rows="10" cols="30">
      <?php echo htmlspecialchars(preg_replace('/\s*\/>/', '>', $_POST['CODEFIXER'])); ?>
    </textarea>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    I just wanna do
    <br> tags to <br /> tags sorry because i have many links on the page and lists and stuff that wouldn't work with that code... sorry

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I just wanna do
    <br> tags to <br /> tags
    Why? That's breaking code (unless you've dropped support for IE and are serving this all as XHTML, which I doubt).
    because i have many links on the page and lists and stuff that wouldn't work with that code
    Why wouldn't they work with it? The combination /> won't appear anywhere in HTML, Javascript, or CSS; there's no reason it should break anything.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    k i don't think this works in html...
    Code:
    <a href="link.html" />CLICK HERE!</a>

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You're right, it doesn't. However, the code I provided won't result in this code: it goes the other way, converting XHTML <br /> to HTML <br>, which IE can handle.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    k
    thanks even though I can't do it by what you say above its nice to know that instead of posting 340million times and then finding out... or worse... lol thanks!

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I can't do it by what you say above
    Why? I don't think you quite understood me. Why do you think you can't use it?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •