Sign in to follow this  
CProgrammer

php array questions

Recommended Posts

Hi guys, I do most of my developing in C++ so I have a quick question on php. It seems arrays in php are basically maps. Is there a way to have a standard array that is stored linearly in memory? Also are arrays passed by value or pointer or reference when passed to functions in php 5? Does adding the array keyword chang anything? -CPrgrammer

Share this post


Link to post
Share on other sites
Quote:
Original post by CProgrammer
Hi guys,

I do most of my developing in C++ so I have a quick question on php. It seems arrays in php are basically maps. Is there a way to have a standard array that is stored linearly in memory?


No, all arrays in PHP are effectively maps. You can of course use them as straight zero-based numerically-indexed arrays.

Quote:
Also are arrays passed by value or pointer or reference when passed to functions in php 5?


They behave as if passed by value. I believe they are actually passed by reference with a copy-on-write mechanic though.

Quote:
Does adding the array keyword chang anything?


It forces the argument to be an array, but that's it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this