Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Ampersand


  • Please log in to reply
39 replies to this topic

#1 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 09 September 2008 - 06:36 PM

For I while, I have been wondering what the & sign means in function declarations. For example:

function myFunction($param1, &$param2) {

}


Thanks

Edited by Lop, 09 September 2008 - 07:28 PM.

  • 0

#2 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 09 September 2008 - 06:39 PM

Excellent question. I wondered that for a while too. The & character allows you to pass a variable by reference. Read this: PHP: References Explained - Manual
  • 0

#3 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 10 September 2008 - 12:18 PM

That's interesting. I've passed references in C#, but never in PHP.

Off-topic: Has Lop risen from the ashes?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#4 adserverexpert

adserverexpert

    CC Newcomer

  • Just Joined
  • PipPip
  • 20 posts

Posted 18 September 2008 - 02:40 AM

php is object oriented programming. its possible only.
  • 0

#5 morefood2001

morefood2001

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1011 posts

Posted 18 September 2008 - 06:16 AM

php is object oriented programming. its possible only.


& refers to object oriented programming, or at minimum functions. However this isn't only in PHP, but also exists in C++ and likely other OOP languages.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#6 ArtoStiloz

ArtoStiloz

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 104 posts

Posted 18 September 2008 - 01:21 PM

I have never used this character, the way you use it.
  • 0

#7 Lop

Lop

    Speaks fluent binary

  • Just Joined
  • PipPipPipPipPipPipPip
  • 1112 posts

Posted 18 September 2008 - 05:58 PM

I have never used this character, the way you use it.


In what ways have you used that character?
  • 0

#8 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 19 September 2008 - 02:03 AM

I have never used this character, the way you use it.


so, because of that, others shouldn't use it either? or what's your point?
  • 0

#9 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 19 September 2008 - 07:50 AM

I've used & as a concatenation operator in VB and a logical operator as &&.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#10 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 19 September 2008 - 10:50 PM

I've used & as a concatenation operator in VB and a logical operator as &&.


Well, I was referring to the context of this forum - PHP, and the && operator is not &. However, PHP does support & as a bitwise operator, though I have never seen it used.
  • 0

#11 ArtoStiloz

ArtoStiloz

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 104 posts

Posted 20 September 2008 - 04:57 AM

so, because of that, others shouldn't use it either? or what's your point?


I just think there are much simpler solutions.
  • 0
[SIGPIC][/SIGPIC]
Http://www.ArtoStiloz.Dk

#12 ArtoStiloz

ArtoStiloz

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 104 posts

Posted 20 September 2008 - 04:58 AM

In what ways have you used that character?


As a substitute for an "AND"
  • 0
[SIGPIC][/SIGPIC]
Http://www.ArtoStiloz.Dk




Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download