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 I
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 intermi
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
s
On 2011-07-6 08:09, "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 advantage of using th
> -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
>
>
&g
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:
>
>define('DIR_JAVA', '/js/');
>
>When you need to use the JavaScript directory you can do this.
>
>
>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 OPs first post...
Thanks,
Ash
http://www.ashleysher
> -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
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 ins
>> 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 wit
On Wed, Jul 6, 2011 at 12:07 PM, Dave Wilson 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 the $$ value of
On 7/6/2011 7:07 AM, Dave Wilson wrote:
Output - {XYZ}
Attempt 2:
Output - {{XYZ}}
No luck there. I did encounter one oddity though:
Output:
PHP Notice: Undefined variable: ABC in /home/wilsond/testScripts/l7.php
on line 3
Which appears to mean that PHP is able to pick up the value of the
2010/3/24 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(ST
On Wed, Mar 24, 2010 at 14:12, Marten Lehmann 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 wor
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:
But why doesn't it work with php-cgi? That's a binary that is calle
On Tue, Mar 23, 2010 at 15:50, Jan G.B. wrote:
>
>
> 2010/3/23 Daniel Egeberg
>>
>> On Tue, Mar 23, 2010 at 11:47, Marten Lehmann wrote:
>> > Hello,
>> >
>> > I found different code examples like this, which use the file handle
>> > STDERR
>> > just like this:
>> >
>> > > > fwrite(STDERR, "hello
2010/3/23 Daniel Egeberg
> On Tue, Mar 23, 2010 at 11:47, Marten Lehmann wrote:
> > Hello,
> >
> > I found different code examples like this, which use the file handle
> STDERR
> > just like this:
> >
> > > fwrite(STDERR, "hello\n");
> > ?>
> >
> > Also, the PHP documentation of input/output st
On Tue, Mar 23, 2010 at 11:47, Marten Lehmann wrote:
> Hello,
>
> I found different code examples like this, which use the file handle STDERR
> just like this:
>
> fwrite(STDERR, "hello\n");
> ?>
>
> Also, the PHP documentation of input/output streams
> (http://php.net/manual/de/wrappers.php.php)
2010/3/23 Marten Lehmann
> Hello,
>
> I found different code examples like this, which use the file handle STDERR
> just like this:
>
> fwrite(STDERR, "hello\n");
> ?>
>
> Also, the PHP documentation of input/output streams (
> http://php.net/manual/de/wrappers.php.php) says:
>
> "It is recommen
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.
Talking
> 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 (
Thanks, will do.
"Red Wingate" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
Give this a read:
http://marc.theaimsgroup.com/?l=php-dev&m=107936530102181&w=2
Am Dienstag, 23. März 2004 15:16 schrieb Red Wingate:
> IIRC it was changed to
> self::CONST_NAME recently
>
> interface Se
Give this a read:
http://marc.theaimsgroup.com/?l=php-dev&m=107936530102181&w=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 = "
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, self
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";
[snip]
Not too fast.
>From http://www.php.net/zend-engine-2.php
PHP 5 introduces per-class constants:
[/snip]
My bad. Still not a bug.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Not too fast.
>From http://www.php.net/zend-engine-2.php
PHP 5 introduces per-class constants:
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[snip]
displayFoo();
?>
The results should display "hello world", but it prints out MY_FOO.
[/snip]
This is not a bug, but a misunderstanding of constants. You have not
defined the constant
define("MY_FOO", "hello world.");
http://us4.php.net/constants
--
PHP General Mailing List (http://
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
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 to
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 d
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,
hi,
you can use constants whenever you want something whose value you don't want changed accidently.for e.g. i use a constant to keep track of the path.
if i am at the root level then i store "./" in it. and if i am one folder under the root then i store "../" in it. now as i tend to name va
-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: http://www.php.
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.
[snip]
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
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:
Had we not used global $variable, the $variable
would not have been available inside the function.
But, the
I get the same results as you using PHP4. I can't explain this, since
constants are supposed to be case sensitive by default. They sure don't act
like they are. Looks like a bug to me.
Kirk
> -Original Message-
> From: almir [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 30, 2001 12:44
-- Quoted from Yahoo! homepage, http://www.yahoo.com
On Wed, 10 Jan 2001, jeff saenz wrote:
> Date: Wed, 10 Jan 2001 12:21:01 -0800
> From: jeff saenz <[EMAIL PROTECTED]>
> To: Joe Stump <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] constants inside of
> define(MAX,2);
> print "the max is MAX";
>
> this obv does not work
print "the max is " . MAX;
--
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 administrators, e-mail: [EMA
ge -
From: "Moritz Petersen" <[EMAIL PROTECTED]>
Sent: Wednesday, January 10, 2001 3:18 PM
Subject: RE: [PHP] constants inside of a string
--
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 administrators, e-mail: [EMAIL PROTECTED]
I'm not sure about that one - I think most variables work. No better way to find
out than to try it ;o)
--Joe
On Wed, Jan 10, 2001 at 12:21:01PM -0800, jeff saenz wrote:
> what about inside of a here doc
>
> print << this is the MAX
> HERE
>
> Joe Stump wrote:
>
> > print "the max is ".M
what about inside of a here doc
print << print "the max is ".MAX;
>
> --Joe
>
> On Wed, Jan 10, 2001 at 12:12:08PM -0800, jeff saenz wrote:
> > how do you use defines inside of a string...
> >
> > e.g.
> >
> > define(MAX,2);
> > print "the max is MAX";
> >
> > this obv does not work
> >
print "the max is ".MAX;
--Joe
On Wed, Jan 10, 2001 at 12:12:08PM -0800, jeff saenz wrote:
> how do you use defines inside of a string...
>
> e.g.
>
> define(MAX,2);
> print "the max is MAX";
>
> this obv does not work
>
> jeff
>
>
> --
> PHP General Mailing List (http://www.php.net/
> how do you use defines inside of a string...
>
> e.g.
>
> define(MAX,2);
> print "the max is MAX";
print "the max is " . MAX;
--
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 a
45 matches
Mail list logo