Vipin Kumar Soni
Vipin Kumar Soni

Reputation: 834

Equivalent PHP language code for C language code using pointers

char *pointer = "Hello";
*pointer++;

Above code is in C language, What would be its equivalent PHP code?

Upvotes: 1

Views: 137

Answers (1)

hek2mgl
hek2mgl

Reputation: 158250

There are no pointers in PHP. You can access several chars of a string using the [] operator. (manual) The following code might do what you need:

 $string = "Hello";
 $position = 0;

 $char0 = $string[$position];
 $char1 = $string[++$position];

Upvotes: 2

Related Questions