Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Code Fixer

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

    Default

    oh, my bad. lol, i read didn't sorry it will work, gosh what am I thinking its all this last minute work for my website...

  2. #12
    Join Date
    Sep 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I would do it this way if i had to write that:

    PHP Code:
    <?php 
    function fixcode($Codefixer){
        
    $Codefixer ereg_replace('<br>''<br />'$Codefixer);
        return 
    $Codefixer;
    }  
    ?> 

    <form action="fix.php" method="post">
    <textarea cols="50" rows="10" name="Codefixer"><?php echo htmlspecialchars(fixcode($_POST["CODEFIXER"])); ?></textarea>
    <input type="submit">
    </form>

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

    Default

    Code:
    function fixcode($Codefixer){ 
        $Codefixer = ereg_replace('<br>', '<br />', $Codefixer); 
        return $Codefixer; 
    }
    But that's essentially one statement. It's really rather pointless having one-statement functions, except for the occasional semantic benefit or where it's likely that the implementation will be changed at a later date, neither of which apply here. Also, using regex-parsing functions for static strings is a great way to waste resources, and we've already determined that it's better to use HTML than XHTML here, so the transformation needs to go the other way.
    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
  •