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
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
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
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
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.
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
-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
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
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
-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
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
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
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
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
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
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,
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
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
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
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
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:
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.
--
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
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.
[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
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:
[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
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;
}
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,
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;
}
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 {
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;
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
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,
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
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
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.
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
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
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
-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:
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
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:
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.
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
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
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
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
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/)
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
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
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
52 matches
Mail list logo