botgaas Posted February 24, 2009 Share Posted February 24, 2009 Question 1: Is there any different between <?php ?> and <? ?> Question 2: As I understood “include” used for include any file. But sometime I saw “include_once” used in some file. But why???? Question 3: I saw some php file extension is “inc.php”, for example – “db.inc.php” or “general.inc.php” my question is what is the reason of using “inc.php” plz plz help me !!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/146731-im-new-here-need-help-plz/ Share on other sites More sharing options...
premiso Posted February 24, 2009 Share Posted February 24, 2009 Questions one, yes <? can be turned off. It is better to use <?php Question two, include_once means it will only include that file once, even if called 5 times. This prevents some errors etc. Question three inc.php is just informing people that it is an include. It is not it's own extension, it just makes it easier in some cases to find out files that are included. Quote Link to comment https://forums.phpfreaks.com/topic/146731-im-new-here-need-help-plz/#findComment-770339 Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 First and formost, you can find ALL of these answers in the PHP documentaion: http://www.php.net/manual/en/ Q1) <? ?> is just a "shorthand" way of doing <?php ?>. I would not recommend using the shorthand method though, because you can configure it to be off. So while your install of PHP might support it, if you take the code somewhere else, it may not work. Q2) The PHP doc describes in detail the difference: http://www.php.net/include/ http://www.php.net/include_once/ http://www.php.net/require/ http://www.php.net/require_once/ Q3) it's just a naming convention to show that the file is an "include" file. So, in essence it's a piece of code, versus an actual script that is executed. Quote Link to comment https://forums.phpfreaks.com/topic/146731-im-new-here-need-help-plz/#findComment-770341 Share on other sites More sharing options...
botgaas Posted February 24, 2009 Author Share Posted February 24, 2009 thanks rhodesa and premiso. im grateful.. Quote Link to comment https://forums.phpfreaks.com/topic/146731-im-new-here-need-help-plz/#findComment-770350 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.