References in PHP vs. pointers in C?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

References in PHP vs. pointers in C?

Post by LonelyProgrammer »

What are the differences, and similiarites, in terms of usage and theory, between PHP's references and C's pointers?

Many thanks in advance!
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

well, for one, you have to load specific libraries when you are gonna use different types of functions in c. in php, you just have to call the functions.

php is basically c with a coding interface like that of delphi or visual basic. i'm not saying the language itself is anything LIKE those 2, but the way it can call functions on the fly without having to call related classes or libraries is where the only similarities occurr (unless, of course, the functions you call have been custom built by yourself i)


if that's not the answer you are looking for, sorry. had to take my contacts out to rest my eyes for a while... and having a -9,-11 vision doens't help.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

a major difference is that a reference in PHP just references (points) to another assigned variable! (In C and Delphi etc a pointer references a memory location and can get lost).
In PHP Passing by reference is most useful when giving a function/method a piece of data to work with and change, I don't see any similarity to e.g. the way you can chain data/records in Pascal..
Post Reply