dfwcomputer Posted March 27, 2008 Share Posted March 27, 2008 If someone could answer these questions it would be greatly appreciated, im pretty sure they all have simple answers and are probably very common questions for people starting out with php. whats the difference between, include("billybob.php"); and include_once("billybob.php"); is one more secure than the other. i see a lot of different scripts using ' and ". e.g. echo '<a href='billybob.php'>BillyBob Rocks</a>'; echo "<a href=\"billybob.php\">BillyBob Rocks</a>"; is there any security issues here, or is one the preferred method, or is it just personal choice. I changed error reporting to E_ALL and i noticed this php notice. Undefined index: HTTP_X_FORWARDED_FOR in billybob.php on Line 53 The original code is; function blocker_iptype2 () { (Line 53) if(isset($_SERVER)) { $_SERVER['HTTP_X_FORWARDED_FOR']; return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif (getenv("HTTP_X_FORWARDED_FOR")) { return getenv("HTTP_X_FORWARDED_FOR"); } else { return "none"; } } Is this a simple fix? Also is there a good article on how php should be written and the actual layout of it....e.g. spaces and is the something out there that you can run code through to make it clean and pretty so to speak. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/98074-some-basic-php-questions-for-beginners/ Share on other sites More sharing options...
Jeremysr Posted March 27, 2008 Share Posted March 27, 2008 include_once() doesn't actually include the file if the file has already been included. Double-quoted strings change variables to their values and change escape characters like "\n" to newlines. $x = 1; $s = 'test'; $string = "$x $s"; $string would equal "1 test". And line 53 should be: if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { return $_SERVER['HTTP_X_FORWARDED_FOR']; } Link to comment https://forums.phpfreaks.com/topic/98074-some-basic-php-questions-for-beginners/#findComment-501785 Share on other sites More sharing options...
Jeremysr Posted March 27, 2008 Share Posted March 27, 2008 Oh and to write "clean" code with white space: Indent all the code "blocks", which are usually the code inside curly brackets: if ($something) { // This code gets indented if ($something_else) { // This code gets indented more } } It's up to you to decide what indent style is best, and where to put spaces and newlines. Click that link (indent style) to see some different styles of indentation. Link to comment https://forums.phpfreaks.com/topic/98074-some-basic-php-questions-for-beginners/#findComment-501788 Share on other sites More sharing options...
dfwcomputer Posted March 27, 2008 Author Share Posted March 27, 2008 thank very much for your reply you cleared it all Link to comment https://forums.phpfreaks.com/topic/98074-some-basic-php-questions-for-beginners/#findComment-501803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.