wood burning stoves 2.0*
The moose likes PHP and the fly likes How to assign random string value to variable in PHP5 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "How to assign random string value to variable in PHP5" Watch "How to assign random string value to variable in PHP5" New topic
Author

How to assign random string value to variable in PHP5

Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Hi All,

I have something like below. want to use any of the random values each time any query happens.


when I tried to run it gave me a error like below
Parse error: syntax error, unexpected '('

I just want to rotate the usernames when ever I query for $user , can you please let me know how to achieve this.


I'm very new to PHP so please bear with my silly syntax questions


Regards, Ricky
Oracle Weblogic 10g Certified Expert TechPaste.Com
Unnar Björnsson
Ranch Hand

Joined: Apr 30, 2005
Posts: 164
If I understand you correctly you want to retrieve a random value from $abc each time an instance of the class is created, in that case you would use rand(minvalue, maxvalue) i.e:
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to assign random string value to variable in PHP5