Re: [PHP] variable type - conversion/checking

2013-03-18 Thread Samuel Lopes Grigolato
Sorry if I'm missing something, there's a lot of replies after my first post on this thread. Is there something wrong with the floor() approach? I liked the regex solution but isn't it more expensive and more verbose than just doing a well commented is_numeric plus floor/ceil math? Just trying

Re: [PHP] variable type - conversion/checking

2013-03-17 Thread Maciek Sokolewicz
On 16-3-2013 19:20, Matijn Woudt wrote: On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg All

Re: [PHP] variable type - conversion/checking

2013-03-17 Thread Matijn Woudt
On Sun, Mar 17, 2013 at 10:20 PM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: On 16-3-2013 19:20, Matijn Woudt wrote: On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: Hi, I have tried to find a way to check if a character string is

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread tamouse mailing lists
On Fri, Mar 15, 2013 at 8:34 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Thu, Mar 14, 2013 at 7:02 PM, georggeorg.chamb...@telia.com** I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! The op wasn't about

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: Guess regex are the only useful solution here. When you consider to use built-in functions, just remember, that for example '0xAF' is an integer too, but '42.00' isn't. Shoot...I hadn't considered how PHP might handle hex or octal

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Andrew Ballard
On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: Guess regex are the only useful solution here. When you consider to use built-in functions, just remember, that for example '0xAF' is an integer too, but

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Ashley Sheridan
On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote: On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: Guess regex are the only useful solution here. When you consider to use built-in functions, just

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Maciek Sokolewicz
Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg All responses in this thread have been very nice; but you could also try a much simpler 2-step check: 1. is_numeric 2. if true check if

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Matijn Woudt
On Sat, Mar 16, 2013 at 6:52 PM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg All responses in this thread have been very nice;

Re: [PHP] variable type - conversion/checking

2013-03-16 Thread Andrew Ballard
On Sat, Mar 16, 2013 at 12:21 PM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Sat, 2013-03-16 at 11:46 -0400, Andrew Ballard wrote: On Mar 16, 2013 6:14 AM, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Fri, 2013-03-15 at 22:32 -0400, Andrew Ballard wrote: Guess regex

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Jim Lucas
On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant)

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Peter Ford
On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan
On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn Woudt wrote: On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread richard gray
On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid number, including a float. For something like

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Jim Lucas
On 03/15/2013 02:33 PM, richard gray wrote: On 15/03/2013 22:00, Ashley Sheridan wrote: On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: For my money, `is_numeric()` does just what I want. The thing is, is_numeric() will not check if a string is a valid int, but any valid

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread tamouse mailing lists
On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13 06:21, Jim Lucas wrote: On 3/14/2013 4:05 PM, Matijn

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Ashley Sheridan
tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55 AM, Peter Ford p...@justcroft.com wrote: On 15/03/13

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try it right now.) Andrew

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Sebastian Krebs
2013/3/16 Ashley Sheridan a...@ashleysheridan.co.uk tamouse mailing lists tamouse.li...@gmail.com wrote: On Fri, Mar 15, 2013 at 4:00 PM, Ashley Sheridan a...@ashleysheridan.co.ukwrote: ** On Fri, 2013-03-15 at 04:57 -0500, tamouse mailing lists wrote: On Fri, Mar 15, 2013 at 3:55

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Sebastian Krebs
2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the original string when cast back to a string, shouldn't it? (I can't try

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
On Mar 15, 2013 9:54 PM, Sebastian Krebs krebs@gmail.com wrote: 2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be identical to the

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Andrew Ballard
Guess regex are the only useful solution here. When you consider to use built-in functions, just remember, that for example '0xAF' is an integer too, but '42.00' isn't. Shoot...I hadn't considered how PHP might handle hex or octal strings when casting to int. (Again, not in front of a computer

Re: [PHP] variable type - conversion/checking

2013-03-15 Thread Matijn Woudt
On Sat, Mar 16, 2013 at 2:54 AM, Sebastian Krebs krebs@gmail.comwrote: 2013/3/16 Andrew Ballard aball...@gmail.com I suppose one could try something like this: if (is_string($val) $val === (string)(int)$val) If $val is an integer masquerading as a string, it should be

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Matijn Woudt
On Thu, Mar 14, 2013 at 7:02 PM, georg georg.chamb...@telia.com wrote: Hi, I have tried to find a way to check if a character string is possible to test whether it is convertible to an intger ! any suggestion ? BR georg You could use is_numeric for that, though it also accepts floats.

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Samuel Lopes Grigolato
Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudt tijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM, georg georg.chamb...@telia.com wrote: Hi, I have

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Jim Lucas
On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM, Matijn Woudttijn...@gmail.com wrote: On Thu, Mar 14, 2013 at 7:02 PM,

Re: [PHP] variable type - conversion/checking

2013-03-14 Thread Matijn Woudt
On Thu, Mar 14, 2013 at 11:44 PM, Jim Lucas li...@cmsws.com wrote: On 03/14/2013 11:50 AM, Samuel Lopes Grigolato wrote: Something like if (is_numeric($var) $var == floor($var)) will do the trick. I don't know if there's a better (more elegant) way. On Thu, Mar 14, 2013 at 3:09 PM,

RE: [PHP] variable placeholders in a text file

2013-01-07 Thread Nelson Green
On Sat, 5 Jan 2013 04:20:09 -0600, Kevin Kinsey wrote: Nelson (et al), I've enjoyed reading this thread and apologize for dredging it up. It's interesting to see your progression of thought and the templating discussion is indeed a worthy one. However, I wanted to answer this objection

Re: [PHP] variable placeholders in a text file

2013-01-04 Thread Kevin Kinsey
On Mon, Dec 31, 2012 at 02:29:38PM -0600, Nelson Green wrote: On Mon, 31 Dec 2012 19:59:02, Ashley Sheridan wrote: ___ On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: snip snip Nelson (et al), I've enjoyed reading this thread and apologize for

RE: [PHP] variable placeholders in a text file

2013-01-01 Thread Nelson Green
While using the *_once works in many cases, if you're doing a mass mailing kind of thing, you want to use the standard include/require so you can re-include it as your variables change: foreach ($customers as $customer) { $fullname = $customer['fullname']; $address = $customer['address'];

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stephen
Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for the expansion. Also consider using HEREDOC instead

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Ashley Sheridan
On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: Hello, I have created a simple function that prints a personalized greeting by reading the greeting contents from a file. I pass the user's name to the function, and the function reads the file contents into a string variable. I am

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stuart Dallas
Please excuse the top post, but this may be helpful: http://stut.net/2008/10/28/snippet-simple-templates-with-php/ -Stuart -- Sent from my leaf blower On 31 Dec 2012, at 19:59, Ashley Sheridan a...@ashleysheridan.co.uk wrote: On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: Hello,

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On Mon, 31 Dec 2012 19:59:02, Ashley Sheridan wrote: ___ On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote:   My question is, is there another way to do something similar, such as embedding a variable name directly into the text file? In other words,

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that $message has to use double quotes for

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread tamouse mailing lists
On Mon, Dec 31, 2012 at 2:37 PM, Nelson Green nelsongree...@hotmail.com wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Bastien
Bastien Koert On 2012-12-31, at 4:58 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: On Mon, Dec 31, 2012 at 2:37 PM, Nelson Green nelsongree...@hotmail.com wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name =

RE: [PHP] variable placeholders in a text file

2012-12-31 Thread Nelson Green
On 2012-12-31, at 4:58 PM, tamouse mailing lists tamouse.li...@gmail.com wrote: I use the include(template) method for this alla time, it works great. Most especially for HTML emails coming from a web site to a group of users, just slick as anything. include does basically just what your

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread Stephen
On 12-12-31 03:37 PM, Nelson Green wrote: On Mon, 31 Dec 2012 14:47:20 Stephen D wrote: Yes! Easy standard stuff. $title = 'Mr.; $user_name = 'John Doe'; $message = Hello $title $user_name Just define the value for the variables before defining the value for the message. Note that

Re: [PHP] variable placeholders in a text file

2012-12-31 Thread tamouse mailing lists
On Mon, Dec 31, 2012 at 5:47 PM, Stephen stephe...@rogers.com wrote: The common stuff for every page is defined in the file include.php. I define the variable $markup in that file. Here is the definition for $markup $markup=HEREDOC [[snippy]] HEREDOC; By using require_once instead of

RE: [PHP] Variable representation

2012-06-21 Thread admin
-Original Message- From: Ron Piggott [mailto:ron.pigg...@actsministries.org] Sent: Thursday, June 21, 2012 3:47 AM To: php-general@lists.php.net Subject: [PHP] Variable representation I am trying to represent the variable: $row['Bible_knowledge_phrase_solver_game_question_topics_1']

Re: [PHP] Variable representation

2012-06-21 Thread As'ad Djamalilleil
or you can do this echo $row[Bible_knowledge_phrase_solver_game_question_topics_$i];

Re: [PHP] Variable Question

2012-04-19 Thread Stuart Dallas
On 19 Apr 2012, at 15:46, Ron Piggott wrote: I am trying to assign variables from an array into variables. This is following a database query. Right now they are in an array: $row[‘word_1’] $row[‘word_2’] $row[‘word_3’] ... $row[‘word_25’] Why those indices? Why isn't it just a

Re: [PHP] Variable Question

2012-04-19 Thread Christoph Boget
I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_25 This should work for you: http://us3.php.net/manual/en/function.extract.php thnx, Christoph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

Re: [PHP] Variable Question

2012-04-19 Thread Shawn McKenzie
On 04/19/2012 09:55 AM, Christoph Boget wrote: I am trying to use this while look to assign them to variables: $word_1 $word_2 $word_3 ... $word_25 This should work for you: http://us3.php.net/manual/en/function.extract.php thnx, Christoph Yes and you can use

Re: [PHP] Variable representation

2012-04-02 Thread Maciek Sokolewicz
On 02-04-2012 07:15, tamouse mailing lists wrote: As for doing what you originally asked, that requires doing an eval() on the statement utilizing string interpolation, like so: eval('echo image $i is $image_' . $i . '.PHP_EOL;'); but I think that's a bit harder to read and understand

Re: [PHP] Variable representation

2012-04-02 Thread tamouse mailing lists
On Mon, Apr 2, 2012 at 4:34 AM, Maciek Sokolewicz maciek.sokolew...@gmail.com wrote: Usually if you think you need to use eval: think again. In this case, it again holds true. Instead of doing what you do, you can also reference the variable as: echo ${'image_'.$i}; or echo

Re: [PHP] Variable representation

2012-04-01 Thread Adam Randall
It would better to just use an array, and then iterate through that. $images[] = stripslashes( $row['image_1'] ); $images[] = stripslashes( $row['image_2'] ); $images[] = stripslashes( $row['image_3'] ); $images[] = stripslashes( $row['image_4'] ); foreach( $images as $k = $v ) { $k++;

Re: [PHP] Variable representation

2012-04-01 Thread Mihamina Rakotomandimby
On 04/02/2012 06:52 AM, Ron Piggott wrote: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes( $row['image_3'] ); $image_4 = stripslashes( $row['image_4'] ); [...] (Not all 4 variables have an image.) How is it meant in the database?

Re: [PHP] Variable representation

2012-04-01 Thread Mihamina Rakotomandimby
On 04/02/2012 07:46 AM, Adam Randall wrote: $images[] = stripslashes( $row['image_1'] ); $images[] = stripslashes( $row['image_2'] ); $images[] = stripslashes( $row['image_3'] ); $images[] = stripslashes( $row['image_4'] ); $images[1] = stripslashes( $row['image_1'] ); $images[2] =

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
On Sun, Apr 1, 2012 at 10:52 PM, Ron Piggott ron.pigg...@actsministries.org wrote: Hi Everyone: I am assigning the value of 4 images to variables following a database query: $image_1 = stripslashes( $row['image_1'] ); $image_2 = stripslashes( $row['image_2'] ); $image_3 = stripslashes(

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
Ugh, gmail mangled the code there. Here's a pastebin of the response which is better formatted: http://pastie.org/3712761 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] Variable representation

2012-04-01 Thread tamouse mailing lists
On Mon, Apr 2, 2012 at 12:20 AM, tamouse mailing lists tamouse.li...@gmail.com wrote: Ugh, gmail mangled the code there. Here's a pastebin of the response which is better formatted: http://pastie.org/3712761 Sweet. I spent so long on my reply, two others snuck in before me. :) -- PHP General

Re: [PHP] Variable number of arguments problem

2012-02-12 Thread Stuart Dallas
On 12 Feb 2012, at 18:51, Tim Streater wrote: I have a function defined thus: function my_func ($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) { // code here } I call this with variously the first three arguments only, or all six, taking care that if I call it with fewer

Re: Re: [PHP] Variable number of arguments problem

2012-02-12 Thread Tim Streater
On 12 Feb 2012 at 19:01, Stuart Dallas stu...@3ft9.com wrote: Optional arguments must be given a default value... function my_func($arg1, $arg2, $arg3, $arg4 = null, $arg5 = null, $arg6 = null) Note that passing a default value by reference was not supported prior to PHP5. All the

Re: [PHP] Variable Troubleshooting Code

2012-01-10 Thread Jim Lucas
On 01/09/2012 07:16 PM, Donovan Brooke wrote: Just to share, a Mr. Harkness forwarded me a consolidated version of my code.. basically substituting the innards for: if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print $key = $valuebr /; } Cheers, Donovan I would

Re: [PHP] Variable Troubleshooting Code

2012-01-10 Thread Donovan Brooke
Jim Lucas wrote: [snip] if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print $key = $valuebr /; } [snip] I would change the above the the following: if ( empty($pmatch) || ( strpos($key, $pmatch) === 0 ) ) { print $key = $valuebr /; } it would be slightly faster

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Marc Guay
some pretty natives php functions exists to do the job : But how many times in my life will I have write echo pre; ??? Does anyone have a handy solution? (Make this the default behavior? Add a even more human-readable flag to the function? Create a simple macro in Aptana 3?) Argz, Marc --

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Ashley Sheridan
Marc Guay marc.g...@gmail.com wrote: some pretty natives php functions exists to do the job : But how many times in my life will I have write echo pre; ??? Does anyone have a handy solution? (Make this the default behavior? Add a even more human-readable flag to the function? Create a simple

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Ashley Sheridan
Ashley Sheridan a...@ashleysheridan.co.uk wrote: Marc Guay marc.g...@gmail.com wrote: some pretty natives php functions exists to do the job : But how many times in my life will I have write echo pre; ??? Does anyone have a handy solution? (Make this the default behavior? Add a even more

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Paul M Foster
On Mon, Jan 09, 2012 at 10:42:59AM -0500, Marc Guay wrote: some pretty natives php functions exists to do the job : But how many times in my life will I have write echo pre; ??? Does anyone have a handy solution? (Make this the default behavior? Add a even more human-readable flag to the

Re: [PHP] Variable Troubleshooting Code

2012-01-09 Thread Donovan Brooke
Just to share, a Mr. Harkness forwarded me a consolidated version of my code.. basically substituting the innards for: if (!isset($pmatch) || substr($key,0,strlen($pmatch)) == $pmatch) { print $key = $valuebr /; } Cheers, Donovan -- D Brooke -- PHP General Mailing List

Re: [PHP] Variable Troubleshooting Code

2012-01-07 Thread David Courtin
Hi, some pretty natives php functions exists to do the job : var_export — Outputs or returns a parsable string representation of a variable debug_zval_dump — Dumps a string representation of an internal zend value to output var_dump — Dumps information about a variable print_r — Prints

Re: [PHP] Variable variable using constant

2011-10-12 Thread Robert Williams
On 10/12/11 11:51, Marc Guay marc.g...@gmail.com wrote: Let's say that I have 2 constants DEFINE('DESKTOP_URL_en', http://www.website.com/index.php?page=home;); DEFINE('DESKTOP_URL_fr', http://www.website.com/index.php?page=accueil;); and I would like to populate the value of an href with them

Re: [PHP] Variable variable using constant

2011-10-12 Thread Marc Guay
  $var = constant('DESKTOP_URL_' . $_SESSION['lang']); Very nice, thank you. Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Variable question

2011-10-03 Thread Ford, Mike
-Original Message- From: Ron Piggott [mailto:ron@actsministries.org] Sent: 01 October 2011 18:59 To: php-general@lists.php.net Subject: [PHP] Variable question If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of

Re: [PHP] Variable question

2011-10-01 Thread Mike Mackintosh
On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo $trivia_answer_$correct_answer;

Re: [PHP] Variable question

2011-10-01 Thread David Harkness
On Sat, Oct 1, 2011 at 10:59 AM, Ron Piggott ron@actsministries.orgwrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? You can use variable variables [1] to access the variable by building its name in a string:

Re: [PHP] Variable question

2011-10-01 Thread Robert Cummings
On 11-10-01 02:03 PM, Mike Mackintosh wrote: On Oct 1, 2011, at 1:59 PM, Ron Piggott wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do:

Re: [PHP] Variable question

2011-10-01 Thread Tim Streater
On 01 Oct 2011 at 18:59, Ron Piggott ron@actsministries.org wrote: If $correct_answer has a value of 3 what is the correct syntax needed to use echo to display the value of $trivia_answer_3? I know this is incorrect, but along the lines of what I am wanting to do: echo

Re: [PHP] Variable question

2011-10-01 Thread Geoff Shang
On Sat, 1 Oct 2011, Mike Mackintosh wrote: Best bet would to toss this into either an object or array for simplification, otherwise that type of syntax would need the use of eval. example: eval('echo $trivia_answer_'.$correct_answer.';'); You could do: $var =

Re: [PHP] Variable scope

2011-07-14 Thread Tamara Temple
On Jul 14, 2011, at 3:54 PM, Karl DeSaulniers wrote: Can anyone explain this to me. function sendEmail($uname,$subjField,$firstname,$lastname,$email, $reply,$e_cc,$e_bcc,$comments,$ip,$Date,$time){ $uname = trim($uname); $subjField = trim($subjField); $firstname =

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Just to clarify, both packages are instantiating and calling their respective database classes from the $db var, which is in the global scope. Is this correct? This is why I hate the global scope, I hate it, I hate it! On Tue, Oct 5, 2010 at 3:47 PM, Brian Smither bhsmit...@gmail.com wrote: I

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread Brian Smither
Just to clarify, both packages are instantiating and calling their respective classes from the $db var, which is in the global scope. Is this correct? I would say yes to the way you are asking. Take the following two applications. The four respective statements are in each their respective

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread chris h
Short of refactoring ApplicationB, can you set it up as a SOAP/REST service that AppA calls? On Tue, Oct 5, 2010 at 5:02 PM, Brian Smither bhsmit...@gmail.com wrote: Just to clarify, both packages are instantiating and calling their respective classes from the $db var, which is in the global

Re: [PHP] Variable (Class instantiation) collision

2010-10-05 Thread David Harkness
If you have total control over application A which contains the bridge code, the easiest is to change it to use a different global variable, $dbA. This must not be doable or you wouldn't have asked. If you have control over the bridge code, and it alone calls A and B, then you could swap the $db

Re: [PHP] Variable in variable.

2010-08-26 Thread Robert Cummings
On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote: I know that in PHP I can use this: $var1 = text; $var2 = '$var1'; 4cho $$var2; So it gives me text. It would if you didn't have typos and the wrong quotes in the above :) My question is, is there a way of doing it with constant like

Re: [PHP] Variable in variable.

2010-08-26 Thread Jo�o C�ndido de Souza Neto
Really cool... Thanks and fogive me by my mistake. hehe -- João Cândido de Souza Neto Robert Cummings rob...@interjinn.com escreveu na mensagem news:4c76743a.2060...@interjinn.com... On 10-08-26 09:54 AM, João Cândido de Souza Neto wrote: I know that in PHP I can use this: $var1 = text;

Re: [PHP] Variable variables into an array.

2010-08-11 Thread Richard Quadling
On 10 August 2010 18:08, Andrew Ballard aball...@gmail.com wrote: On Tue, Aug 10, 2010 at 12:23 PM, Richard Quadling rquadl...@gmail.com wrote: On 10 August 2010 16:49, Jim Lucas li...@cmsws.com wrote: Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong...

RE: [PHP] Variable variables into an array.

2010-08-11 Thread Bob McConnell
From: Richard Quadling Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... ?php $Set = array(); $Entry = 'Set[1]'; ^^ Shouldn't that be $Set[1]? $Value = 'Assigned'; $$Entry = $Value; print_r($Set); ? Bob McConnell -- PHP

Re: [PHP] Variable variables into an array.

2010-08-11 Thread Richard Quadling
On 11 August 2010 13:58, Bob McConnell r...@cbord.com wrote: From: Richard Quadling Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... ?php $Set = array(); $Entry = 'Set[1]';            ^^ Shouldn't that be $Set[1]? $Value = 'Assigned';

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Jim Lucas
Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... ?php $Set = array(); $Entry = 'Set[1]'; $Value = 'Assigned'; $$Entry = $Value; print_r($Set); ? The output is an empty array. Examining $GLOBALS, I end up with an

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Richard Quadling
On 10 August 2010 16:49, Jim Lucas li...@cmsws.com wrote: Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... ?php $Set = array(); $Entry = 'Set[1]'; $Value = 'Assigned'; $$Entry = $Value; print_r($Set); ? The

Re: [PHP] Variable variables into an array.

2010-08-10 Thread Andrew Ballard
On Tue, Aug 10, 2010 at 12:23 PM, Richard Quadling rquadl...@gmail.com wrote: On 10 August 2010 16:49, Jim Lucas li...@cmsws.com wrote: Richard Quadling wrote: Hi. Quick set of eyes needed to see what I've done wrong... The following is a reduced example ... ?php $Set = array(); $Entry

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Ashley Sheridan
On Mon, 2009-10-05 at 16:56 +0200, Dotan Cohen wrote: I need to store a variable name as a variable. Note quite a C-style pointer, but a way to access one variable who's name is stored in another variable. As part of a spam-control measure, a certain public-facing form will have dummy

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Tommy Pham
- Original Message From: Dotan Cohen dotanco...@gmail.com To: php-general. php-general@lists.php.net Sent: Mon, October 5, 2009 7:56:48 AM Subject: [PHP] Variable name as a variable? I need to store a variable name as a variable. Note quite a C-style pointer, but a way to access

Re: [PHP] Variable name as a variable?

2009-10-05 Thread Lars Torben Wilson
On Mon, 5 Oct 2009 16:56:48 +0200 Dotan Cohen dotanco...@gmail.com wrote: I need to store a variable name as a variable. Note quite a C-style pointer, but a way to access one variable who's name is stored in another variable. As part of a spam-control measure, a certain public-facing form

Re: [PHP] variable

2009-09-24 Thread Tommy Pham
- Original Message From: Grega Leskovšek legr...@gmail.com To: php-general@lists.php.net Sent: Thursday, September 24, 2009 10:10:33 AM Subject: [PHP] variable Suppose I have a variable $i = 0 or 1 or 2 and I have variables $item0, $item1 and $item2 how do I print the variable

Re: [PHP] variable

2009-09-24 Thread Tommy Pham
- Original Message From: Tommy Pham tommy...@yahoo.com To: Grega Leskovšek legr...@gmail.com; php-general@lists.php.net Sent: Thursday, September 24, 2009 10:16:44 AM Subject: Re: [PHP] variable - Original Message From: Grega Leskovšek To: php-general

Re: [PHP] variable

2009-09-24 Thread Ben Dunlap
Suppose I have a variable $i = 0 or 1 or 2 and I have variables $item0, $item1 and $item2 how do I print the variable $item0 using a combination of variable $item and variable $i? or with this code it gives me an error: $i = 0; $item0 = test; echo $item$i; #how do I properly use this

Re: [PHP] variable

2009-09-24 Thread Lars Nielsen
Hi Grega I think you might want to have a look at the array's section of the php manual. http://www.php.net/array regards Lars tor, 24 09 2009 kl. 19:10 +0200, skrev Grega Leskovšek: Suppose I have a variable $i = 0 or 1 or 2 and I have variables $item0, $item1 and $item2 how do I print the

Re: [PHP] Variable formatting problem using sessions...

2009-01-26 Thread Chris
Rick Duval wrote: I'm using an OnClick routine to set a session variable before I go to another page. onClick=?php $_SESSION['local_part']= 'rick'; ? works fine but I need a variable where rick is I've tried onClick=?php $_SESSION['local_part']= $local_part; ? and other variations but it

Re: [PHP] variable probe revision

2009-01-12 Thread Ashley Sheridan
On Mon, 2009-01-12 at 16:11 -0500, Frank Stanovcak wrote: I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func already defined errors. Here is a revision incase anyone decided to use it that will work multiple times in the

Re: [PHP] variable probe revision

2009-01-12 Thread Frank Stanovcak
Ashley Sheridan a...@ashleysheridan.co.uk wrote in message news:1231796437.3558.62.ca...@localhost.localdomain... On Mon, 2009-01-12 at 16:11 -0500, Frank Stanovcak wrote: I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func

Re: [PHP] variable probe revision

2009-01-12 Thread Chris
Frank Stanovcak wrote: I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func already defined errors. Here is a revision incase anyone decided to use it that will work multiple times in the same script for variable watching.

Re: [PHP] variable probe revision

2009-01-12 Thread Frank Stanovcak
Chris dmag...@gmail.com wrote in message news:496bbd52.2080...@gmail.com... Frank Stanovcak wrote: I posted this once before, and then tried to use it multiple times in a script. As you can guess I got a bunch of func already defined errors. Here is a revision incase anyone decided to use

[PHP] Re: Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-24 Thread tedd
At 11:06 AM +1100 12/24/08, Clancy wrote: On Tue, 23 Dec 2008 10:25:13 -0500, tedd.sperl...@gmail.com (tedd) wrote: Two things: 1. One statement, one line. 2. The code between the two examples is different; produces different results; and thus is rather pointless in making a definitive

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread German Geek
oops, yes of course lol Tim-Hinnerk Heuer http://www.ihostnz.com On Tue, Dec 23, 2008 at 7:43 PM, Lars Torben Wilson larstor...@gmail.comwrote: 2008/12/22 German Geek geek...@gmail.com: agree, ++$i wont save u nething, it just means that the variable is incremented after it is used: You

Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread Clancy
On Mon, 22 Dec 2008 22:40:58 -0800, larstor...@gmail.com (Lars Torben Wilson) wrote: Well, in all fairness, it *is* faster--but you'll only notice the difference in extremely tight and long-running loops (try it ;) ). As long as you know why you're using it and what the side effects are, it

[PHP] Assignment (Was Re: [PHP] More microptimisation (Was Re: [PHP] Variable as an index)

2008-12-23 Thread tedd
At 9:10 AM +1100 12/23/08, Clancy wrote: Schlossnagle (in Advanced PHP Programming) advises: $i = 0; while ($i $j) { ++$i; } rather than: $i = 0; while ($i $j) { ... $i++; } as the former apparently uses less

  1   2   3   4   5   6   >