TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-08-2010, 09:42 PM   #1 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Arrow Changable value

hey I've little question;

PHP Code:
$get $_REQUEST['NUMBER'];
$num."".$get "blbla";

echo 
$num3
// should echo blbla

I have to echo the changable value name. But its not correct. How do you think I can get it in correct way ?
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 10-08-2010, 09:53 PM   #2 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by CΛSTΞX View Post
hey I've little question;

PHP Code:
$get $_REQUEST['NUMBER'];
$num."".$get "blbla";

echo 
$num3
// should echo blbla

I have to echo the changable value name. But its not correct. How do you think I can get it in correct way ?
What you are doing is impossible. You can not name variables like they are strings. Your closest match would be to use an array.

PHP Code:
$get $_REQUEST['NUMBER'];
$num[$get] = "blbla";

echo 
$num[$get]; 
__________________

Village Idiot is offline  
Reply With Quote
Old 10-08-2010, 10:13 PM   #3 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

Variable variables: http://php.net/manual/en/language.va...s.variable.php

I'm not sure if you can combine two variables like this

PHP Code:
${$num $get
But one variable works

PHP Code:
$var $num $get;
$
$var 
__________________
Eric
wGEric is offline  
Reply With Quote
Old 10-08-2010, 10:14 PM   #4 (permalink)
The Acquainted
 
Join Date: Feb 2008
Posts: 107
Thanks: 3
CΛSTΞX is on a distinguished road
Default

Thanks Eric, that is interesting. I wasn't know that.
__________________
Downloadic
infolizer
Send a message via MSN to CΛSTΞX
CΛSTΞX is offline  
Reply With Quote
Old 10-09-2010, 08:00 AM   #5 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

See also: http://cowburn.info/2008/01/12/php-vars-curly-braces/
Salathe is offline  
Reply With Quote
Old 10-09-2010, 05:07 PM   #6 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,299
Thanks: 17
Village Idiot is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
Interesting, I never knew one could do that... I do know that I will never use it though.
__________________

Village Idiot is offline  
Reply With Quote
Old 10-09-2010, 08:29 PM   #7 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

(removed by suggestion)
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı

Last edited by delayedinsanity : 10-10-2010 at 11:57 PM.
delayedinsanity is offline  
Reply With Quote
Old 10-10-2010, 11:34 PM   #8 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

Quote:
Originally Posted by Village Idiot View Post
Interesting, I never knew one could do that... I do know that I will never use it though.
Absolutely the right stance to take.

A rare example of curly-brace-madness being useful comes from lovely web APIs provided by big names (here's looking at you Google and Yahoo!) which provide JSON-formatted responses containing identifiers like foo$bar or foo:bar which when converted directly to stdClass properties (via json_decode) cannot be accessed with the normal syntax (e.g. $object->foo$bar), calling for something like $object->{'foo$bar'} instead.

As for actual variables names, I can't think of the last time that I used the ${...} syntax for production code outside of a double-quoted string; I'm uncertain if it has ever happened.

Quote:
Originally Posted by delayedinsanity View Post
... I just like coming up with fictional new ways to get back ...
How about you keep this kind of stuff to yourself, next time? Thanks.
Salathe is offline  
Reply With Quote
Old 10-10-2010, 11:58 PM   #9 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

Alrighty, point taken.
__________________
uʍop ǝpısdn sı ɹǝʇndɯoɔ ɹnoʎ sıɥʇ pɐǝɹ uɐɔ noʎ ɟı
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:48 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design