Re: include

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim Streater <tim@xxxxxxxxxxxxxxxx> wrote:
> I'm looking for confirmation that:
> 
>   include $fn;
> 
> is an allowed form of the include statement.

Yes, it is definitely allowed. The syntactic sugar of using parens
around the include subject is optional, as it is in other parts of php
as well. That said, it's usually better to include the syntactic sugar
so as to make future maintenance concerns easier -- there's less chance
of a future change to introduce an error if it's clear what things are
grouped with what. Much less of a concern in this case, but more of a
concern in, say, compound expressions.

<?php
$fn="foo.ext";
include $fn;
include "$fn";
include ($fn);
include ("$fn");
?>

are all equivalent, because php interpolates variable references in
double quoted strings.

<?php
include '$fn';
?>

however is not.

> > While it's certainly possible to rig up something using sockets, I don't
> > think that's how AJAX works, and you'd need a JS library that did.
> 
> Hmmm, I think perhaps I've not made myself clear - sorry about that. At present I'm using AJAX and apache; I'd like to *stop* doing that (and not use another web server, either). In my case, client and server are the same machine - the user's machine. There is a browser window and JavaScript within it which makes the AJAX requests. I just happen to use apache to have a variety of PHP scripts run to provide results back to the browser window.
> 
> > Generally, you should only really need to dynamically replace parts of a
> > long-running program if you don't want to restart it. However, php
> > scripts are not long-running programs in general, unlike the apache
> > server itself, for example, and certainly if the php scripts are running
> > under apache, they will be time- and space-limited by whatever is set in
> > the php.ini file. If these little scripts are merely responding to AJAX
> > requests, they should be really short-lived.
> 
> At present these scripts generally are short-lived, but with some notable exceptions. Hence my exploration of whether I could use websockets instead.

Ah, okay, I'm not at all familiar with websockets, so I'm going to have
to step out of this. Good luck with it!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux