Here you will find the new official reference manuals. These documents are related to the core of TYPO3 and address the built in functionality of TYPO3. They are designed to provide you with in-depth information.
- Coding Guidelines
- Core Api Reference
- File Abstraction Layer
- Inside TYPO3
- TSconfig Reference
- Typoscript Reference
- Typoscript Syntax
- TYPO3 Services
Old Core Documentation
Global variables should be named in uppercase.
Variables with a large scope should have long names, variables with a small scope can have short names. Temporary variables are best kept short. Someone reading such variables should be able to assume that its value is not used outside a few lines of code.
Common temporary variables are $i, $j, $k, $m and $n. Since these variables should have small scope prefixes are a bit of overkill.
Always access GET and POST vars by a TYPO3 API function (and directly through HTTP_GET_VARS or $_GET or the same for POST)
t3lib_div::_GET() : will return the current global HTTP_GET_VARS (unescaped recursively)
t3lib_div::_POST() : will return the current global HTTP_POST_VARS (unescaped recursively)
t3lib_div::_GP($var) : will return a POST or GET var by name $var, with priority to POST (unescaped recursively)
If you need to set a value in HTTP_GET_VARS globally, always use t3lib_div::_GETset() to write back the HTTP_GET_VARS array (will set both HTTP_GET_VARS and the superglobal $_GET)
If you access values directly in HTTP_GET_VARS/HTTP_POST_VARS you MUST only do so if your code acts if there are no slashes on the values! (It is not allowed to check magic_quotes settings since TYPO3 will normalize the arrays no matter what!)
It is also acceptable to use HTTP_GET_VARS and HTTP_POST_VARS directly if you use such as isset() to check whether a value is set.
If possible, group requests after input variables in an init() function of your classes - thus it is clear to see what external input your application expects. (There are multiple examples in the core of the init() function loading all input variables into internal vars of the class by a series of t3lib_div::_GP() function calls!)
Do NOT expect in your scripts that input from outside is found in the global vars. It's recommended to use the php.ini-optimized with TYPO3 and that means that the content of HTTP_POST/GET_VARS is NOT transferred to the global name-space.
t3lib_div::_GET(), t3lib_div::_POST() and t3lib_div::_GP() always return a value which is unescaped regardless of PHP settings for magic_quotes. (This is one reason to use them!)
$myName = t3lib_div::_GP('myname');
$myName = t3lib_div::_GET('myname');
$myName = t3lib_div::_POST('myname');
$myName = $GLOBALS['myname'];
$myName = $GLOBALS['HTTP_POST_VARS']['myname'];
Generally keep variables safe inside of classes in whatever work you do with TYPO3.
Use a namespace for your GET and POST variables in extensions:If you want to make a form-field with the email address, name it:
<input name="tx_myext[email]"> or <input name="tx_myext[DATA][email]">
Apply the same principles of naming on GET vars as well. You can retrieve that array by a simple function call to t3lib_div::_GP('tx_myext'); or t3lib_div::_GET('tx_myext'); Please see the Extension API and tutorials in this regard for more guidelines.
Notice: For a list of global variables and constants available in the TYPO3 core see the document "TYPO3 Core API"!
In any case you want to use any of the system variables below, please DO NOT use getenv(), preferably not HTTP_SERVER_VARS either, but call the API function t3lib_div::getIndpEnv().
Follow these guidelines:
Never use getenv()
Always use the t3lib_div::getIndpEnv() function if you can. You can depend on those values, that they will work on any platform TYPO3 supports.
If you really need a variable from HTTP_SERVER_VARS for some reason, you can most likely do so. You may then help us testing the availability of this variable on a variety of systems and suggest to include it as a key in t3lib_div::getIndpEnv().
The whole point of this is to have an “abstraction method” for returning these values regardless of TYPO3 running on a UNIX or WINDOWS server, Apache or ISS, CGI or module. Some of these variables are different from system to system, some does not even exist on some servers, some are swapped around depending on SAPI-type and the story goes on. The declared target of this function, t3lib_div::getIndpEnv(), is to deliver a system independant value which you can always trust to be correct. If its not, we are going to fix it.
Many, many reported bugs in TYPO3 has been due to these variables returning different values. People have then tried to fix it and found a fix which works on their system, but which would break another system. Therefore this function is really necessary. And unfortunately changing it for a certain non-supported setup can only be done with extensive testing afterwards - we don't want to break TYPO3 on systems that do work!
If you need a system variable which is not listed below, please investigate the cross-platform/cross-webserver availability and suggest an addition.
Please see the documentation inside the t3lib_div::getIndpEnv() function for the most up-to-date information.
First some definition of terms:
output from parse_url():
[scheme] => 'http'
[user] => 'username'
[pass] => 'password'
[host] => '192.168.1.4'
[port] => '8080'
[path] => '/typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/'
[query] => 'arg1,arg2,arg3&p1=parameter1&p2[key]=value'
[fragment] => 'link1'
Further definition: [path_script] = '/typo3/32/temp/phpcheck/index.php'
[path_dir] = '/typo3/32/temp/phpcheck/'
[path_info] = '/arg1/arg2/arg3/'
[path] = [path_script/path_dir][path_info]
NOTICE THAT SCRIPT_NAME will return the php-script name ALSO. [path_script] may not do that (eg. "/somedir/" may result in SCRIPT_NAME "/somedir/index.php")!
[path_info] = /arg1/arg2/arg3/
(Does not work with CGI-versions AFAIK)
[host][:[port]] = 192.168.1.4:8080
[path]?[query] = /typo3/32/temp/phpcheck/index.php/arg1/arg2/arg3/?arg1,arg2,arg3&p1=parameter1&p2[key]=value
Suggestion. This is very usefull to make self-referencing URLs or “returnUrl”'s in scripts! Eg in a parameter string:
(client user agent)
(client accept language)
Absolute filename of script(Differs between windows/unix). On windows "C:\\blabla\\blabl\\" will be converted to "C:/blabla/blabl/"
Absolute path of root of documents:DOCUMENT_ROOT.SCRIPT_NAME = SCRIPT_FILENAME
Special TYPO3 extras:
[port]= 8080 (blank if 80, taken from host value)
[scheme]://[host][:[port]][path]?[query](sheme will by default be "http" until we can detect if it's https -
[scheme]://[host][:[port]][path_dir] of the TYPO3 websites root