Jump to content

markjoe

Members
  • Posts

    226
  • Joined

  • Last visited

    Never

Posts posted by markjoe

  1. If you haven't found the characters being output, keep looking, you missed it/them. Did you try viewing the files with a hex editor? (such as XVI32 if you're on Windows)

    This also includes blank lines after the ?> in "geoip.inc". (which is why i recommend not using closing tags at all)

    Saying you're looking for html output is not promising, you need to look for any and all bytes that may be output to the browser.

  2. if you're getting "Cannot modify header information - headers already sent", you positively have output being sent before your header() call.

    check "geoip.inc" also, if that has anything outside the <?php ?> tags, it will cause it too.

    If you still cannot find the offending characters, use a hex editor to check the actual bytes in the file in case there is some non-printing char that you text editor doesn't understand.

  3. I don't think I can agree that a Singleton class is equivalent to global variables. Sure they certainly can be overused, but everything can.

    There are plenty problems that are perfectly solved by a Singleton class. (like when pooling database connections or threads)

    The situations that call for a Singleton, I'd guess, should only occur once or twice in a typical application, IF at all.

     

    for the record, I think global variables are much more offensive that Singletons.

  4. If you database engine does not support transactions, you can build larger queries and then update them.

    I've had to do this in the past where a script was updating thousands of records in a loop. I chucked the queries into 100, I think, and it ran much faster.

  5. Already doubting there to be any significant difference in speed, I decided to do a crude test anyway.

    I did 20,000 lines of each pattern

    echo "<div/>HTML</div>\n";
    echo "<div>PHP ". ++$a . "</div>\n"; 
    echo "<div/>HTML</div>\n";
    echo "<div>PHP ". ++$a . "</div>\n"; 
    echo "<div/>HTML</div>\n";
    echo "<div>PHP ". ++$a . "</div>\n"; 

    <div/>HTML</div>
    <?php echo "<div>PHP ". ++$a . "</div>\n"; ?>
    <div/>HTML</div>
    <?php echo "<div>PHP ". ++$a . "</div>\n"; ?>
    <div/>HTML</div>
    <?php echo "<div>PHP ". ++$a . "</div>\n"; ?>
    <div/>HTML</div>
    <?php echo "<div>PHP ". ++$a . "</div>\n"; ?>

    with and without APC

    There was no noticeable difference in execution time.

    (the standard deviation of each was greater than any of the differences between them)

    As for security, I am not aware of any concerns either way.

     

    My advice: between these two methods and the HEREDOC, choose which ever you want based on keeping the code clean and easy to maintain.

  6. Woops I didn't look at the code structure close enough. You should absolutely never "weave" code, like teynon previously said. Open and close tags should always be "symmetrical".

    But other than that point, I cannot find any reason why this wouldn't be acceptable:

    <div class="description">
    
    <a href="Documentary.php?playThis=valley" target="_self" >
    <div class="descriptionInner">
    	<img src="images/logos/valley.gif" width="160" height="95" />
    	California Valley<br/>
    	 hicking in california<br/>
    </div>
    <div>
    	<span class="timeShow">
    		08:15
    	</span>
    </div>
    </a>
    
    <hr class="blueLine">
    </div>

     

    Granted, I wouldn't do it myself, but I cannot find any spec that says you can't.

  7. I agree it looks "iffy", but I don't find anything to suggest it is not allowed.

    In fact to the contrary, the specs seem to suggest that it is allowed.

    While they do not give any examples of an anchor tag containing other tags, the only limitation explicitly listed for anchor content is that it may not contain another anchor tag.

    http://www.w3.org/TR/html401/struct/links.html#edef-A

    http://www.w3.org/TR/xhtml1/#prohibitions

  8. you are telling it to do 2 things at once and the form submission will (I think) always win.

    Get rid of the click handler on the submit button. Just define the function.

    function growl(){
    $.growlUI('Growl Notification', 'Have a nice day!'); 
    }

    and then tell it to run when the form is submitted

    <form -snip- onsubmit="return growl();">

    having the return in the onsubmit attribute allows you to return false from the function to cancel the submission if you please.

     

  9. it looks like your cloning the valores1 <ol> with the

    var newElem = $('#input' + num).clone(true).prop('id', 'input' + newNum);

    call.

    I think the first argument to clone clones the contents also.

    When I change to this:

    $(document).ready(function() {
        for ($i=0; $i<4; $i++) {
            var num = $('.clonedInput').length;
            
            var newNum = new Number(num + 1);
            
            var newElem = $('#input' + num).clone(true).prop('id', 'input' + newNum);
            //var newElem1 = $('#valores' + num).clone(true).prop('id', 'valores' + newNum);
            
    
            $('#input' + num).after(newElem);
            //$('#valores' + num).insertAfter(newElem1);
    
        }
    
        });

     

    the output does not change.

  10. My point is don't do this:

    <?php
    require('header.php');
    // where header.php prints out html code or whatever
    class Item{
    function Item($name){
    	$this->name = $name;
    }
    }
    
    foreach($some_array as $element){
    $i = new Item($element);
    echo $i->name;
    }

     

    Yes, you will always have some mixture since PHP is not 100% OOP (insert Ruby plug here), but the very least you should do is keep your class definitions separate.

  11. Object Oriented Programming (classes/methods) aka OOP and functional programming can each perform the same tasks.

    You won't gain some amazing functionality using one or the other. One or the other may be better suited for a specific task, however.

    OOP can usually save you some typing by re-using more code, however, many "proper" OOP designs will actually be more work upfront (but save time later).

    PHP OOP is a bit of an odd thing being that it is a "bolt-on". I would strongly recommend to keep to one or the other style when developing in PHP. Having functional and OOP styles mixed in the same files will turn into a nightmare.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.