Re: [PHP] Constants in strings

2011-07-08 Thread Pete Ford
On 06/07/11 17:33, Robert Williams wrote: Where I've made most use of heredocs is when I want to do nothing but define a bunch of long strings in one file. I find the most useful thing about heredocs is that they don't care about quotation marks, so I often use them for SQL statements where

[PHP] Constants in strings

2011-07-06 Thread Dave Wilson
Hi all, OK. We all know that constants cannot be accessed directly via their name in double-quoted or heredoc strings. I knew this already but a read of the PHP manual got me thinking. The manual states that to get the $$ value of a variable, the form {${var}} should be used. Therefore, I

Re: [PHP] Constants in strings

2011-07-06 Thread Curtis Maurand
On 7/6/2011 7:07 AM, Dave Wilson wrote: Output - {XYZ} Attempt 2: ?php define ('XYZ','ABC'); echo {{XYZ}}\n; ? Output - {{XYZ}} No luck there. I did encounter one oddity though: ?php define ('XYZ','ABC'); echo {${XYZ}}\n; ? Output: PHP Notice: Undefined variable: ABC in

Re: [PHP] Constants in strings

2011-07-06 Thread Stuart Dallas
On Wed, Jul 6, 2011 at 12:07 PM, Dave Wilson dai_bac...@hotmail.com wrote: Hi all, OK. We all know that constants cannot be accessed directly via their name in double-quoted or heredoc strings. I knew this already but a read of the PHP manual got me thinking. The manual states that to get

Re: [PHP] Constants in strings

2011-07-06 Thread Ashley Sheridan
Any ideas? echo XYZ . \n; --Curtis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Which doesn't answer the original question Dave asked... Thanks, Ash http://www.ashleysheridan.co.uk -- Sent from my Android phone with K-9 Mail.

Re: [PHP] Constants in strings

2011-07-06 Thread Dave Wilson
On Wed, 06 Jul 2011 12:56:21 +0100, Stuart Dallas wrote: My guess is that the preceding $ causes PHP to interpret the next token {XYZ} as a variable or a constant, but without that preceding $ it has no way to know you're trying to use a constant. As Curtis points out, the only way to insert a

RE: [PHP] Constants in strings

2011-07-06 Thread admin
-Original Message- From: Dave Wilson [mailto:dai_bac...@hotmail.com] Sent: Wednesday, July 06, 2011 10:11 AM To: php-general@lists.php.net Subject: Re: [PHP] Constants in strings On Wed, 06 Jul 2011 12:56:21 +0100, Stuart Dallas wrote: My guess is that the preceding $ causes PHP

RE: [PHP] Constants in strings

2011-07-06 Thread Ashley Sheridan
define('DIR_JAVA', '/js/'); When you need to use the JavaScript directory you can do this. script src=?php echo DIR_JAVA . 'jquery-1.5.1.js';?/script There is no true need for the curly brackets to echo out the value of the constant. Except for when you're using heredoc, much like in the

RE: [PHP] Constants in strings

2011-07-06 Thread Curtis Maurand
Yeah, that was my answer and I was rebuked for that. ad...@buskirkgraphics.com wrote: -Original Message- From: Dave Wilson [mailto:dai_bac...@hotmail.com] Sent: Wednesday, July 06, 2011 10:11 AM To: php-general@lists.php.net Subject: Re: [PHP] Constants in strings On Wed, 06 Jul

RE: [PHP] Constants in strings

2011-07-06 Thread admin
-Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Wednesday, July 06, 2011 10:49 AM To: ad...@buskirkgraphics.com; 'Dave Wilson'; php-general@lists.php.net Subject: RE: [PHP] Constants in strings define('DIR_JAVA', '/js/'); When you need

Re: [PHP] Constants in strings

2011-07-06 Thread Robert Williams
On 2011-07-6 08:09, ad...@buskirkgraphics.com ad...@buskirkgraphics.com wrote: I use constants in my OOP and I never use the heredoc syntax. Now I am fearing that I have not taken advantage of something. My understanding of heredoc syntax as of 5.3 is just a string quoting right? Is there an

Re: [PHP] Constants in strings

2011-07-06 Thread Jim Giner
I LOVE the heredocs tool. I only learned about it a couple of months ago - what a find! It makes generating my html for my web pages so much easier and allows me to include my php vars within the html with much less confusion and simplifies the intermixing of html and php vars - no more

Re: [PHP] Constants in strings

2011-07-06 Thread Robert Cummings
On 11-07-06 02:59 PM, Jim Giner wrote: I LOVE the heredocs tool. I only learned about it a couple of months ago - what a find! It makes generating my html for my web pages so much easier and allows me to include my php vars within the html with much less confusion and simplifies the

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-24 Thread Marten Lehmann
Hello, dan...@daniel-laptop:~$ php test.php /dev/null Error 1 Error 2 dan...@daniel-laptop:~$ ./src/php-5.2.12/sapi/cli/php test.php /dev/null Error 1 Error 2 well, using php-cli instead of php-cgi, this finally worked: ? fwrite(STDERR, test\n); fclose(STDERR); ? But why doesn't it work

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-24 Thread Daniel Egeberg
On Wed, Mar 24, 2010 at 14:12, Marten Lehmann lehm...@cnm.de wrote: Hello, dan...@daniel-laptop:~$ php test.php  /dev/null Error 1 Error 2 dan...@daniel-laptop:~$ ./src/php-5.2.12/sapi/cli/php test.php  /dev/null Error 1 Error 2 well, using php-cli instead of php-cgi, this finally

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-24 Thread Jan G.B.
2010/3/24 Marten Lehmann lehm...@cnm.de Hello, dan...@daniel-laptop:~$ php test.php /dev/null Error 1 Error 2 dan...@daniel-laptop:~$ ./src/php-5.2.12/sapi/cli/php test.php /dev/null Error 1 Error 2 well, using php-cli instead of php-cgi, this finally worked: ? fwrite(STDERR,

[PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-23 Thread Marten Lehmann
Hello, I found different code examples like this, which use the file handle STDERR just like this: ?php fwrite(STDERR, hello\n); ? Also, the PHP documentation of input/output streams (http://php.net/manual/de/wrappers.php.php) says: It is recommended that you simply use the constants

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-23 Thread Jan G.B.
2010/3/23 Marten Lehmann lehm...@cnm.de Hello, I found different code examples like this, which use the file handle STDERR just like this: ?php fwrite(STDERR, hello\n); ? Also, the PHP documentation of input/output streams ( http://php.net/manual/de/wrappers.php.php) says: It is

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-23 Thread Daniel Egeberg
On Tue, Mar 23, 2010 at 11:47, Marten Lehmann lehm...@cnm.de wrote: Hello, I found different code examples like this, which use the file handle STDERR just like this: ?php fwrite(STDERR, hello\n); ? Also, the PHP documentation of input/output streams

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-23 Thread Jan G.B.
2010/3/23 Daniel Egeberg degeb...@php.net On Tue, Mar 23, 2010 at 11:47, Marten Lehmann lehm...@cnm.de wrote: Hello, I found different code examples like this, which use the file handle STDERR just like this: ?php fwrite(STDERR, hello\n); ? Also, the PHP documentation of

Re: [PHP] constants STDOUT, STDERR, STDIN not working in 5.2.x?

2010-03-23 Thread Daniel Egeberg
On Tue, Mar 23, 2010 at 15:50, Jan G.B. ro0ot.w...@googlemail.com wrote: 2010/3/23 Daniel Egeberg degeb...@php.net On Tue, Mar 23, 2010 at 11:47, Marten Lehmann lehm...@cnm.de wrote: Hello, I found different code examples like this, which use the file handle STDERR just like this:

[PHP] CONSTANTS and good coding practice

2004-05-21 Thread Al
Can someone explain to me the value of using defined custom constants, in the context of good coding practice. I don't recall ever seeing define() used in the scripts I've seen and only the characteristics are described in the my php book and the php manual; but, not the use. Thanks. --

Re: [PHP] CONSTANTS and good coding practice

2004-05-21 Thread Matt
From: Al [EMAIL PROTECTED] Friday, May 21, 2004 9:02 AM Subject: [PHP] CONSTANTS and good coding practice Can someone explain to me the value of using defined custom constants, in the context of good coding practice. Constants are useful anywhere you find yourself typing a constant (i.e

Re: [PHP] CONSTANTS and good coding practice

2004-05-21 Thread Jordi Canals
Al wrote: Can someone explain to me the value of using defined custom constants, in the context of good coding practice. I don't recall ever seeing define() used in the scripts I've seen and only the characteristics are described in the my php book and the php manual; but, not the use.

RE: [PHP] Constants

2004-03-23 Thread Jay Blanchard
[snip] ?php interface Foo { const MY_FOO = hello world; } class Bar implements Foo { public function displayFoo(){ print MY_FOO; } } $obj = new Bar; $obj-displayFoo(); ? The results should display hello world, but it prints out MY_FOO. [/snip] This is not a bug, but

RE: [PHP] Constants

2004-03-23 Thread Vincent Jansen
Not too fast. From http://www.php.net/zend-engine-2.php PHP 5 introduces per-class constants: ?php class Foo { const constant = constant; } echo Foo::constant = . Foo::constant . \n; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

RE: [PHP] Constants

2004-03-23 Thread Jay Blanchard
[snip] Not too fast. From http://www.php.net/zend-engine-2.php PHP 5 introduces per-class constants: ?php class Foo { const constant = constant; } echo Foo::constant = . Foo::constant . \n; ? [/snip] My bad. Still not a bug. -- PHP General Mailing List (http://www.php.net/) To

Re: [PHP] Constants

2004-03-23 Thread Jakes
If you define constants with in a interface and then implement that interface it does not work on 5RC1 This should work, but it displays the constant name rather than value it references interface Settings { const UNAME = somename; const PWORD = password; const SERVER = localhost; }

Re: [PHP] Constants

2004-03-23 Thread Red Wingate
IIRC it was changed to self::CONST_NAME recently interface Settings { const UNAME = somename; const PWORD = password; const SERVER = localhost; } class Conn implements Settings { public function __construct(){ $dbConn = mysql_connect(self::SERVER, self::UNAME,

Re: [PHP] Constants

2004-03-23 Thread Red Wingate
Give this a read: http://marc.theaimsgroup.com/?l=php-devm=107936530102181w=2 Am Dienstag, 23. März 2004 15:16 schrieb Red Wingate: IIRC it was changed to self::CONST_NAME recently interface Settings { const UNAME = somename; const PWORD = password; const SERVER = localhost; }

Re: [PHP] Constants

2004-03-23 Thread Jakes
Thanks, will do. Red Wingate [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Give this a read: http://marc.theaimsgroup.com/?l=php-devm=107936530102181w=2 Am Dienstag, 23. März 2004 15:16 schrieb Red Wingate: IIRC it was changed to self::CONST_NAME recently interface Settings {

[PHP] Constants

2004-03-22 Thread Jakes
The bug server looks like its down, so I will just post the bug here, and hopefully someone will spot it PHP version: 5RC1 ?php interface Foo { const MY_FOO = hello world; } class Bar implements Foo { public function displayFoo(){ print MY_FOO; } } $obj = new Bar;

[PHP] Constants in class definitions

2004-02-23 Thread Toro Hill
Hi all. I was wondering if using defined constants in class definitions is completely legal (or even good practice) in PHP. For example, ?php define( CONSTANT, hello ); class Yep{ $var stuff = array( CONSTANT = 'two' ); } ? I've looked throught the PHP documentation and from what I can tell it

Re: [PHP] Constants in class definitions

2004-02-23 Thread Richard Davey
Hello Toro, Tuesday, February 24, 2004, 12:22:29 AM, you wrote: TH Hi all. TH I was wondering if using defined constants in class definitions TH is completely legal (or even good practice) in PHP. I see absolutely no reason why not. Constants are just ways of defining non-changing variables,

Re: [PHP] Constants in class definitions

2004-02-23 Thread Adam Bregenzer
On Tue, 2004-02-24 at 08:22, Toro Hill wrote: I've looked throught the PHP documentation and from what I can tell it is legal. I'm using PHP4.3.4, and haven't had any problems with class definitions like this. I use constants in classes myself without problems. In PHP 5 you can actually

Re: [PHP] Constants in class definitions

2004-02-23 Thread Toro Hill
Hi Adam. I was wondering if using defined constants in class definitions is completely legal (or even good practice) in PHP. I've looked throught the PHP documentation and from what I can tell it is legal. However, I've had some problems with Turck MMCache and class definitions that are similar

Re: [PHP] Constants in class definitions

2004-02-23 Thread Adam Bregenzer
On Tue, 2004-02-24 at 09:26, Toro Hill wrote: Here's the situation: PHP 4.3.4 Apache 1.3.29 MMCache 2.4.6 I'm ending up with some garbage in certain class variables. The code runs fine without MMCache disabled. There seems to be a very specific circumstances under which the error occurs.

[PHP] constants

2003-07-21 Thread Michael Müller
hi, why should I use constants? thx for help Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP] constants

2003-07-21 Thread Haseeb
L PROTECTED] Subject: [PHP] constants hi, why should I use constants? thx for help Michael -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php IncrediMail - Email has finally evolved - Click Here

[PHP] Constants in heredoc strings?

2003-06-27 Thread Jeff Stewart
Is there a way to expand constants in heredoc strings without assigning the constant's value to a variable first? -- Jeff S. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Constants in heredoc strings?

2003-06-27 Thread Ford, Mike [LSS]
-Original Message- From: Jeff Stewart Is there a way to expand constants in heredoc strings without assigning the constant's value to a variable first? -- No. Cheers! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:

[PHP] Constants and Here Document Interpolation

2003-03-01 Thread Daniel R. Hansen
Can anyone tell me if it is possible (and how) to use defined constants within here document content? I've not been successful finding anything on this in the online docs. Thanks! Dan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP] Constants and Here Document Interpolation

2003-03-01 Thread Danny Shepherd
Hello, It doesn't look like it - a note in the constants manual entry reads: PHP has no way of recognizing the constant from any other string of characters within the heredoc block Danny. -Original Message- From: Daniel R. Hansen [mailto:[EMAIL PROTECTED] Sent: 01 March 2003 15:57 To:

Re: [PHP] Constants and Here Document Interpolation

2003-03-01 Thread Ernest E Vogelsinger
At 16:56 01.03.2003, Daniel R. Hansen said: [snip] Can anyone tell me if it is possible (and how) to use defined constants within here document content? I've not been successful finding anything on this in the online docs.

FW: [PHP] Constants and Here Document Interpolation

2003-03-01 Thread Daniel R. Hansen
Actually I did try it and couldn't think of a way to work around the matter. Thanks for the suggestion. -Original Message- From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED] Sent: Saturday, March 01, 2003 12:56 PM To: Daniel R. Hansen Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Constants

Re: FW: [PHP] Constants and Here Document Interpolation

2003-03-01 Thread Ernest E Vogelsinger
At 19:28 01.03.2003, Daniel R. Hansen said: [snip] Actually I did try it and couldn't think of a way to work around the matter. Thanks for the suggestion. -Original Message- From: Ernest E Vogelsinger [mailto:[EMAIL PROTECTED] You simply could have

[PHP] Constants for dummies, please?

2003-02-21 Thread Chris Corwin
Help, please -- I've just started looking at my first line of PHP code. :) A little background, I am *not really* a programmer: I went to art school. I have taught myself to develop web stuff in another language: Lasso, but have no training. In any case, I am looking through a php script

Re: [PHP] Constants for dummies, please?

2003-02-21 Thread Philip Olson
Some thoughts on variables and constants: a) You can't redefine a constant but can redefine a variable. b) Constants are autoglobal (like superglobals) so for example: ?php define ('CONSTANT', 'some value'); $variable = 'some value'; function foo() { global

[PHP] constants and sessions

2002-11-12 Thread Eduardo M. Bragatto
I have to change the constant maximum_time_out (via set_timeout_limit) on the first script, and keep it seted in a session, until the second script became to be loaded. Is that possible? [[]]'s Bragatto PS: sorry for my miserable english #) -- PHP General Mailing List (http://www.php.net/)

[PHP] constants and case sensitivity

2001-03-30 Thread almir
just when I thought , nice I didn't know how does it work i found out that it is not wroking anyhow if I put define ("rights", "RIGHTS", X); define ("Rights", "RIGHTS", X); echo rights . "-" .defined("rights") ." " .Rights ."-" .defined("Rights")."br"; regardless of X i always get RIGHTS-1

RE: [PHP] constants and case sensitivity

2001-03-30 Thread Johnson, Kirk
PM To: [EMAIL PROTECTED] Subject: [PHP] constants and case sensitivity just when I thought , nice I didn't know how does it work i found out that it is not wroking anyhow if I put define ("rights", "RIGHTS", X); define ("Rights", "RIGHTS", X

Re: [PHP] constants inside of a string

2001-01-10 Thread Toby Butzon
etersen" [EMAIL PROTECTED] Sent: Wednesday, January 10, 2001 3:18 PM Subject: RE: [PHP] constants inside of a string snip -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list