PHP mysql_client_encoding() function
Definition and Usage
The mysql_client_encoding() function returns the name of the character set of the current connection.
Syntax
mysql_client_encoding(link_identifier)
Parameters | Description |
---|---|
link_identifier | Required. MySQL's connection identifier. If not specified, the last one used is mysql_connect() Open connection. If the connection is not found, the function will try to call mysql_connect() Establishes a connection and uses it. If an error occurs, no connection is found or the connection cannot be established, the system emits a warning message at the E_WARNING level. |
Description
Gives the value of the character_set variable from MySQL.
Return Value
Returns the name of the default character set of the current connection.
Example
<?php $con = mysql_connect("localhost","mysql_user","mysql_pwd"); if (!$con) { die("Could not connect: " . mysql_error()); } $charset = mysql_client_encoding($con); echo "The current character set is: $charset"; mysql_close($con); ?>
Output:
The current character set is: latin1