Connecting Tech Pros Worldwide Forums | Help | Site Map

Variable Types question

tony@tony.com
Guest
 
Posts: n/a
#1: Jul 1 '06

Does PHP have a byte or character type ?

If I do

$email = "tony@tony.com";
echo $email[0];

I can get the letter "t"

However according to the documentation (and my tests) this is not being
extracted as a character but a string.

How can I extract just the character itself ?

To test this you can do this:

echo ((int)$email[0]);
and it returns 0.


is there a character (byte) type at all ?

tony



Ken Robinson
Guest
 
Posts: n/a
#2: Jul 1 '06

re: Variable Types question



tony@tony.com wrote:[color=blue]
> Does PHP have a byte or character type ?
>
> If I do
>
> $email = "tony@tony.com";
> echo $email[0];
>
> I can get the letter "t"
>
> However according to the documentation (and my tests) this is not being
> extracted as a character but a string.
>
> How can I extract just the character itself ?[/color]

That is the letter itself. What, precisely are you trying to do?[color=blue]
>
> To test this you can do this:
>
> echo ((int)$email[0]);
> and it returns 0.[/color]

In order to get the numerical value of a character, you need to use the
ord() fuction. <http://www.php.net/ord>

Ken

Closed Thread