FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » require*/include*: compile-time or runtime?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
require*/include*: compile-time or runtime? [message #170919] Wed, 08 December 2010 15:25 Go to next message
A.Reader is currently offline  A.Reader
Messages: 15
Registered: December 2010
Karma: 0
Junior Member
It's not documented, that I can find, whether these includes are
performed at compile-time or jit/run-time. I can write some code to
work it out, but if someone's already done that it would save
wheel-reinvention.

Thanks upfront.
Re: require*/include*: compile-time or runtime? [message #170920 is a reply to message #170919] Wed, 08 December 2010 15:46 Go to previous messageGo to next message
Willem Bogaerts is currently offline  Willem Bogaerts
Messages: 8
Registered: September 2010
Karma: 0
Junior Member
On 08/12/10 16:25, A.Reader wrote:
> It's not documented, that I can find, whether these includes are
> performed at compile-time or jit/run-time. I can write some code to
> work it out, but if someone's already done that it would save
> wheel-reinvention.
>
> Thanks upfront.

As you can return a value from an include and can "require" a file from
a computed location, I'd say this is done at runtime.

You can do things like:

require_once(dirname(__FILE__) .
'/../hashingcontrolfiller/hashingcontrolfiller.php');

Things that are done at compile time usually do not tolerate such
expressions.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Re: require*/include*: compile-time or runtime? [message #170922 is a reply to message #170919] Wed, 08 December 2010 19:30 Go to previous messageGo to next message
pakalk is currently offline  pakalk
Messages: 3
Registered: December 2010
Karma: 0
Junior Member
On 8 Gru, 16:25, A.Reader<anonym...@example.org> wrote:
> It's not documented, that I can find, whether these includes are
> performed at compile-time or jit/run-time.  I can write some code to
> work it out, but if someone's already done that it would save
> wheel-reinvention.

What compile-time instructions do u know in interpreted language?
Re: require*/include*: compile-time or runtime? [message #170927 is a reply to message #170922] Thu, 09 December 2010 00:11 Go to previous messageGo to next message
Helmut Chang is currently offline  Helmut Chang
Messages: 22
Registered: September 2010
Karma: 0
Junior Member
Am 08.12.2010 20:30, schrieb pakalk:

> What compile-time instructions do u know in interpreted language?

"Interpreted language" doesn't mean, the code isn't compiled. The
difference is, that a program, written in an interpreted language is
compiled each time, (before) the program runs.

And there are compile-time instructions in PHP. An example are class
constants. Those are evaluated during compile time and therefore you
cannot use constructs like:

const FOO = 'Foo'.'Bar';

or

const BAR = 1 + 2;
Re: require*/include*: compile-time or runtime? [message #170932 is a reply to message #170927] Thu, 09 December 2010 05:32 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/8/2010 7:11 PM, Helmut Chang wrote:
> Am 08.12.2010 20:30, schrieb pakalk:
>
>> What compile-time instructions do u know in interpreted language?
>
> "Interpreted language" doesn't mean, the code isn't compiled. The
> difference is, that a program, written in an interpreted language is
> compiled each time, (before) the program runs.
>
> And there are compile-time instructions in PHP. An example are class
> constants. Those are evaluated during compile time and therefore you
> cannot use constructs like:
>
> const FOO = 'Foo'.'Bar';
>
> or
>
> const BAR = 1 + 2;
>

Yes, unfortunately, this is still a shortcoming in PHP. A good
compile/interpreter should be able to handle both cases.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: require*/include*: compile-time or runtime? [message #171035 is a reply to message #170927] Wed, 15 December 2010 16:39 Go to previous messageGo to next message
pakalk is currently offline  pakalk
Messages: 3
Registered: December 2010
Karma: 0
Junior Member
On 9 Gru, 01:11, Helmut Chang <use...@helmutchang.at> wrote:
>
> const FOO = 'Foo'.'Bar';
>
> or
>
> const BAR = 1 + 2;

Are you sure it is executed at compile-time?
Re: require*/include*: compile-time or runtime? [message #171036 is a reply to message #171035] Wed, 15 December 2010 17:37 Go to previous messageGo to next message
Magno is currently offline  Magno
Messages: 49
Registered: October 2010
Karma: 0
Member
On 12/15/2010 01:39 PM, pakalk wrote:
> On 9 Gru, 01:11, Helmut Chang<use...@helmutchang.at> wrote:
>>
>> const FOO = 'Foo'.'Bar';
>>
>> or
>>
>> const BAR = 1 + 2;
>
> Are you sure it is executed at compile-time?

I am not sure about this, but if you ask me... using that “const”
construct, it is not possible to do what pakalk is telling.

It is possible with define() though.
Re: require*/include*: compile-time or runtime? [message #171037 is a reply to message #171035] Wed, 15 December 2010 18:14 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/15/2010 11:39 AM, pakalk wrote:
> On 9 Gru, 01:11, Helmut Chang<use...@helmutchang.at> wrote:
>>
>> const FOO = 'Foo'.'Bar';
>>
>> or
>>
>> const BAR = 1 + 2;
>
> Are you sure it is executed at compile-time?

He is correct. Constants are evaluated at compile time, which is why
you cannot use an expression to initialize them.

When you think about it, it makes sense. A constant is only evaluated
once, not every time you go past the definition (i.e. in a function).

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: require*/include*: compile-time or runtime? [message #171040 is a reply to message #171037] Wed, 15 December 2010 19:48 Go to previous messageGo to next message
pakalk is currently offline  pakalk
Messages: 3
Registered: December 2010
Karma: 0
Junior Member
On 15 Gru, 19:14, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> On 12/15/2010 11:39 AM, pakalk wrote:
>
>> On 9 Gru, 01:11, Helmut Chang<use...@helmutchang.at>  wrote:
>
>>> const FOO = 'Foo'.'Bar';
>
>>> or
>
>>> const BAR = 1 + 2;
>
>> Are you sure it is executed at compile-time?
>
> He is correct.  Constants are evaluated at compile time, which is why
> you cannot use an expression to initialize them.
>
> When you think about it, it makes sense.  A constant is only evaluated
> once, not every time you go past the definition (i.e. in a function).
>

Of course, it should be constant :) But I do not know if parse error
is constant evaluation error ;) I mean.. it is syntax error, widely-
considered instruction is not executed.

Nevermind :) I am too poor in english to provide my point of view
clearly :D (But I think about: "compile-time instruction" == "can do
sth during compile-time", not "it is parsed at compile-time")

Include/require are both run-time.
Re: require*/include*: compile-time or runtime? [message #171041 is a reply to message #171040] Wed, 15 December 2010 21:03 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 12/15/2010 2:48 PM, pakalk wrote:
> On 15 Gru, 19:14, Jerry Stuckle<jstuck...@attglobal.net> wrote:
>> On 12/15/2010 11:39 AM, pakalk wrote:
>>
>>> On 9 Gru, 01:11, Helmut Chang<use...@helmutchang.at> wrote:
>>
>>>> const FOO = 'Foo'.'Bar';
>>
>>>> or
>>
>>>> const BAR = 1 + 2;
>>
>>> Are you sure it is executed at compile-time?
>>
>> He is correct. Constants are evaluated at compile time, which is why
>> you cannot use an expression to initialize them.
>>
>> When you think about it, it makes sense. A constant is only evaluated
>> once, not every time you go past the definition (i.e. in a function).
>>
>
> Of course, it should be constant :) But I do not know if parse error
> is constant evaluation error ;) I mean.. it is syntax error, widely-
> considered instruction is not executed.
>
> Nevermind :) I am too poor in english to provide my point of view
> clearly :D (But I think about: "compile-time instruction" == "can do
> sth during compile-time", not "it is parsed at compile-time")
>
> Include/require are both run-time.

If there is a syntax error, NO instructions are executed. Parsing stops
at the syntax error and the process does not continue to execution.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: drupal php google analytics
Next Topic: Adsense approval Trick
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 17:33:23 GMT 2024

Total time taken to generate the page: 0.03109 seconds