Jump to content

Search the Community

Showing results for tags 'xdebug'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 1 result

  1. (Based on earlier writings by "So Called" in this topic)1. Organization tips for all of programming 1.1. Start smallMake your big problems into little problems! Don't write 200 lines of code and then ask us why it doesn't work! Instead, write 10 or 20 lines of code and get that to work. Other things being equal, 20 lines of code will have 1/10 as many bugs as 200 lines of code. You are 10 times as likely to write good code if you write just a little not a lot, and 10 times more likely to have willing volunteers on the forum help you find out why it doesn't work. On a related note, don't write a whole mess of HTML, PHP and MySQL queries (even if it's well under 200 lines of code) and then ask yourself (or the forum) why it doesn't work. Write a few lines, test it, fix what's broke, then add more code. Don't add more complexity until you get what you've already written to work. This is the stage where you can expect help from an Internet forum. 1.2. Keep it readableSpeaking of creating a mess, avoid creating one by keeping your code readable. A lot of problems can be avoided or fixed quickly if you and other people can find their way around your code. You might have overlooked this as a "minor feature", but it's actually really important for this point - you can freely insert white space between different parts of your PHP code. This means you can (and should) insert white space wherever it makes logical sense. If you're not sure, err on the side of being with white space. For example, instead of <?php$f=$_GET['f'];$l=$_GET['l'];$r=0;for($i=0;$i<100;$i++) if($i%2===0||$i%5===0)$r+=$i;echo "$f $l: $r"; make that <?php$f = $_GET['f'];$l = $_GET['l']; $r = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $r += $i; echo "$f $l: $r"; Also, use meaningful variable names that tell you what a variable is used for. For example, instead of the above, have it as <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $result += $i; echo "$firstName $lastName: $result"; And finally, if brackets/braces/whatever are allowed, but optional, use them anyway, to clearly define the intended boundaries, e.g.: <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) { if (($i % 2 === 0) || ($i % 5 === 0)) { $result += $i; }} echo "{$firstName} {$lastName}: {$result}"; If you search the web, you'll find different advises on how much and where should white spaces and brackets/braces be (e.g. some programmers prefer the opening bracket on a new line, while others prefer it on the same line as the statement - as above). No style is truly "better" than another. Whatever feels readable to you, use that. However, it's important to note: Whatever your preference is, be consistent. Don't use one style at one place, and another style at another place, as this makes your code harder to read.(Also worth noting: Some PHP editors allow you, with the click of a button, to automatically add white spaces according to predefined rules, so that at least the first part of what we did above is automated) 1.3. Probe your codeAsking for help on the forum may get you help in hours, days or sometimes weeks. But ask your code the same questions and you may get answers in seconds or (at worst) minutes! The remainder of this topic will address how you can ask your code to tell you why it won't work. These things are not "fixes", they're means to finding a fix (which is essentially what "debugging" means).
  • Create New...