PHP token_name() Function Last Updated : 25 Aug, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report The token_name() function is an inbuilt function in PHP that is used to retrieve the textual representation of a given token identifier. In PHP, when you write code, it gets parsed into a series of tokens, which are the basic units of code that the interpreter understands. These tokens include keywords, operators, constants, variables, and other elements of the code. Syntax: string token_name(int $token)Parameters: This function accepts only one parameter which is described below. $token: An integer representing a token constant.Return Value: The token_name() function returns the symbolic name of the given token. Program 1: The following program demonstrates the token_name() function. PHP <?php // Example token constant $token = T_IF; $tokenName = token_name($token); echo "Token name for $token: $tokenName"; ?> OutputToken name for 322: T_IFProgram 2: The following program demonstrates the token_name() function. PHP <?php // Example token constants $tokens = [T_IF, T_ECHO, T_FOREACH]; foreach ($tokens as $token) { $tokenName = token_name($token); echo "Token name for $token: $tokenName\n"; } ?> OutputToken name for 322: T_IF Token name for 324: T_ECHO Token name for 330: T_FOREACH Reference: https://www.php.net/manual/en/function.token-name.php Comment More infoAdvertise with us Next Article PHP tempnam() Function N neeraj3304 Follow Improve Article Tags : PHP PHP-function Similar Reads PHP | timezone_name_get() Function The timezone_name_get() function is an inbuilt function in PHP which is used to return the name of the timezone. The date time object is sent as a parameter to the timezone_name_get() function and it returns the name of the timezone on success or False on failure. Syntax: string timezone_name_get( $ 2 min read PHP | Reflection getName() Function The Reflection::getName() function is an inbuilt function in PHP which is used to return the name of the specified class. Syntax: string Reflection::getName( void ) Parameters: This function does not accept any parameters. Return Value: This function returns the name of the specified class. Below pr 1 min read PHP | time() Function The time() function is a built-in function in PHP which returns the current time measured in the number of seconds since the Unix Epoch. The number of seconds can be converted to the current date using date() function in PHP. Syntax: int time() Parameter: This function does not accepts any parameter 2 min read PHP tempnam() Function The tempnam() function is an inbuilt function in PHP that helps in creating a file having a unique file name by setting the access permission to 0600, having the specified directory. This function then generates the file in the system's temporary directory, if the specified directory does not exist 2 min read PHP | gethostname() Function The gethostname() function is an inbuilt function in PHP which returns the host or domain name for the local machine. This function is applicable after PHP 5.3.0 before that there was another function called php_uname function. Syntax: string gethostname( void ) Parameters: This function doesn't acc 1 min read PHP | zip_entry_name() Function The zip_entry_name() function is an inbuilt function in PHP which is used to return the name of a zip archive entry. The zip entry resource is to be read and sent as a parameter to the zip_entry_name() function and it returns the name of the zip entry archive on Success. Syntax: string zip_entry_nam 2 min read Like