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

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

3
  • 6
    Since PHP doesn't have pointers, there's no equivalent. What does this code do that you want to replicate in PHP? Commented Nov 18, 2013 at 11:06
  • There are no pointers in PHP. While they share a somewhat similar syntax, PHP is not C. Commented Nov 18, 2013 at 11:08
  • PHP doesnt have pointers, so you wont have any equivalent code for that. Whats the intention behind this code, there might be a function which does that. Commented Nov 18, 2013 at 11:08

1 Answer 1

2

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];
Sign up to request clarification or add additional context in comments.

1 Comment

I think you want a pre-increment operator here, you're just getting char0 twice... :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.