php-general Digest 12 Oct 2011 18:51:39 -0000 Issue 7516
Topics (messages 315246 through 315252):
Re: Server Side Include translator as PHP functions
315246 by: tamouse mailing lists
CGI PHP vs. FastCGI vs. mod_php vs. application server?
315247 by: saeed ahmed
315250 by: Richard Quadling
315251 by: Mike Mackintosh
Re: files outside of documentRoot
315248 by: Ricardo Martinez
Re: How to know the path of `php.ini` used when call php.exe from
CLI/command-line in Windows 7
315249 by: Richard Quadling
Variable variable using constant
315252 by: Marc Guay
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Sun, Oct 9, 2011 at 12:36 PM, Tedd Sperling <tedd.sperl...@gmail.com> wrote:
> On Oct 9, 2011, at 11:41 AM, Complex wrote:
>
>> Tedd,
>>
>> The crucial detail you're lookign for is my lack of choice or control
>> in the matter, for all sorts of reasons that are actually quite stupid
>> but not possible for *me* to change, and not possible for anyone else
>> to change quickly. Thus I am looking for a solution to the problem at
>> hand, instead of a suggestion for what the entire org should be doing
>> instead. I know what they should be doing instead, but that's not my
>> decision. It's not like I'm building a new website this way; I'm
>> trying to move forwards with an existing and large website. The more
>> different code-bases we have for different parts of the site, the
>> harder it will be to actually change to something else (PHP-based, I
>> pray).
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> Without debating the question of choice, if I was confronted with a large web
> site that used SSI, I would inform the client of such and put together a bid
> as to my time to bring the site up to date. If not, then I think I would pass
> on working the site. In my experience, it's not worth my additional time to
> try to work around "out of date" technologies.
>
> It is also been my experience that when I am confronted with something large
> scale, and when approved by the client, I simply do a site-wide find and
> replace (namely change "<!--#include" to "<?php include") and then evaluate
> all occurrences prior to changing. That usually gives me a good idea of the
> breath of the problem.
>
> In addition, considering the "<!--#include" has basically the same purpose as
> "<?php include", while it may be a wide-spread problem, I do not see it as a
> serious problem to address. Certainly, when including files that have a
> different suffix ".shtml" as compared to ".php" you will find that the Server
> will treat them differently but that's pretty easy to fix -- just change the
> files suffix or possibility write code in a .httacess file that would cause
> the interpreter to consider shtml files the same a php.
>
> Of course, I may not fully understand the problem.
Of course, if it was just mapping includes, that would be too simple
to require much of a general solution. However SSI is more than just
includes. That's where it gets interesting.
--- End Message ---
--- Begin Message ---
greeting all,
As far as I know, there are different ways to write a PHP application:
- CGI, ie. the usual way : some PHP code in web pages, and the PHP
interpreter is loaded each time a PHP page is called
- FastCGI : apparently, the interpreter is loaded at boot time; the
application itself might also be compiled and loaded once
- mod_php : same as FastCGI?
- application server : the application is compiled and loaded once;
the application can either have its own web server, or use a web
server as front end, and only handle its own part
Any tips much appreciated, thank you.
--
Saeed Ahmed
Junior Software engineer
Codemate Ltd <http://www.codemate.com>.
My Blog: saeedahmed.net
--- End Message ---
--- Begin Message ---
On 12 October 2011 09:19, saeed ahmed <saeed....@gmail.com> wrote:
> greeting all,
>
> As far as I know, there are different ways to write a PHP application:
> - CGI, ie. the usual way : some PHP code in web pages, and the PHP
> interpreter is loaded each time a PHP page is called
> - FastCGI : apparently, the interpreter is loaded at boot time; the
> application itself might also be compiled and loaded once
> - mod_php : same as FastCGI?
> - application server : the application is compiled and loaded once;
> the application can either have its own web server, or use a web
> server as front end, and only handle its own part
>
> Any tips much appreciated, thank you.
Each of the SAPIs operate in different environments (though I suppose
CGI and FastCGI are going to nearly be swappable).
CGI - As you rightly say, is loaded on a per-request basis. There is
an overhead for every request to get PHP up and running prior to
processing the PHP script.
Fast-CGI - This requires some cooperation from the server. The server
will create a set of PHP instances (separate executable, not running
in the same memory space as the server) ready to receive the script.
This reduces the overhead that exists with CGI from request loading to
server startup/loading.
mod_php - I'm on Windows and have not used Apache. But I have used
ISAPI. I believe these operate in a similar fashion. In this instance,
the PHP interpreter is loaded as a module of the server, just like any
other module the server loads. Each PHP script is handled by a
separate PHP thread. These threads are NOT separate instances of PHP,
and are running within the same address space as the web server. As a
consequence, several features/issues exist. Chiefly for me was the
persistent database connections. As the same module of code is running
all the scripts, a script can (by the use of the appropriate
functions) get the database connection remembered between each script.
This allows faster connection to the DB for each script. There are
issues though. The connection is to the SERVER and not to the DB. The
remembered connection is based upon the server, the username and
password. If you use multiple databases on the same connection AND use
the selectDB functionality, the single remembered DB connection will
change DB. If this happens midscript, you could end up in a very
strange place. But, if you use qualified naming
(database_name.owner.table_name for an MS SQL example), then you will
be fine. Just remember select DB is just a shortcut for the connection
to use. It isn't part of the connection.
Application Server - Don't know.
You also have ...
CLI - Command line PHP scripting. You must manually invoke PHP with
the script name for it to run, though Windows has some useful features
to allow you to run a PHP script without having to declare the PHP
executable every time. I think the #! line is the Unix equivalent of
this feature, but isn't as complete as the Windows mechanism (IMHO) -
See http://docs.php.net/manual/en/install.windows.commandline.php for
additional details on this.
And as of 5.4, there is CLI Server. This is using PHP to run as a
listener on the HTTP port and passes requests to a simple, userland,
PHP-based routing script which will allow you to respond to PHP
requests. See http://docs.php.net/manual/en/features.commandline.webserver.php
for more details.
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---
--- Begin Message ---
Nice write up Richard
On Oct 12, 2011, at 7:06, Richard Quadling <rquadl...@gmail.com> wrote:
--- End Message ---
--- Begin Message ---
It works thx a lot =)
On Tue, Oct 11, 2011 at 5:26 PM, Bastien Koert <phps...@gmail.com> wrote:
> On Tue, Oct 11, 2011 at 11:00 AM, Ricardo Martinez <harisel...@gmail.com>
> wrote:
> > Hi!
> >
> > i'm was checking, readfile(); and fpassthru();
> >
> > With easy examples, i can use it for show a pic in the screen and
> download a
> > file, from outside of documentRoot. It works fine.
> >
> > The problem that i have now, is, i need can work with it, inside of other
> > documents, but i'm getting all time error by the headers. ( already sendt
> > ... )
> >
> > Anyone knows how to use it for can call the files and work together with
> > other page ¿?
> >
> > Thanks
> >
> > On Sun, Oct 9, 2011 at 6:57 PM, Sean Greenslade <zootboys...@gmail.com
> >wrote:
> >
> >>
> >> On Sun, Oct 9, 2011 at 9:52 AM, Ricardo Martinez <harisel...@gmail.com
> >wrote:
> >>
> >>> The files are, png, pdf and flv.
> >>>
> >>> Only users login can see or download it.
> >>>
> >>> thx ;>
> >>>
> >>> On Sat, Oct 8, 2011 at 11:16 PM, Shawn McKenzie <nos...@mckenzies.net
> >>> >wrote:
> >>>
> >>> > On 10/08/2011 03:40 PM, Ricardo Martinez wrote:
> >>> > > Hi List!
> >>> > >
> >>> > > I need to access files outside the DocumentRoot.
> >>> > >
> >>> > > I've been looking for info and documentation, and I've read that it
> >>> can
> >>> > be
> >>> > > done using symbolic links and another way is by using headers.
> >>> > >
> >>> > > I want to know, what do you think, what is the best way, and if
> anyone
> >>> > knows
> >>> > > a good doc about of it.
> >>> > >
> >>> > > Thanks!!!
> >>> > >
> >>> >
> >>> > It depends on what you mean by "files". Are they PHP files that need
> to
> >>> > be run, or images, or files that need to be downloaded by the user?
> >>> >
> >>> > For PHP, you would add the external dir to your include path.
> >>> >
> >>> > For images you can use a php file as the img src and that file sets
> the
> >>> > appropriate headers and uses readfile() to get and echo the image
> data:
> >>> > getimage.php?image=someimage.gif
> >>> >
> >>> > For download files you would do it in the same manner as for images:
> >>> > download.php?file=somefile.zip
> >>> >
> >>> >
> >>> > --
> >>> > Thanks!
> >>> > -Shawn
> >>> > http://www.spidean.com
> >>> >
> >>>
> >>> --
> >>> Ricardo
> >>> _______________________________________________
> >>> IT Architect
> >>> website: http://www.pulsarinara.com
> >>>
> >>
> >>
> >> Sounds like the downloader php script would be perfect (what Shawn
> >> suggested). Have the script check the login status, then (if valid) send
> the
> >> proper headers for the file and read out the data with the script.
> >>
> >> --
> >> --Zootboy
> >>
> >> Sent from my PC.
> >>
> >>
> >
> >
> > --
> > Ricardo
> > _______________________________________________
> > IT Architect
> > website: http://www.pulsarinara.com
> >
>
> For images and the like, I have a separate page that is called that
> handles the image and the headers needed
>
> In the page I have some thing like
>
> echo "<img src='get_image.php?id=$id'>";
>
> Then in the get-image.php page i have the code that gets the image
> from the db, outputs the appropriate headers and then outputs the
> image
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
--
Ricardo
_______________________________________________
IT Architect
website: http://www.pulsarinara.com
--- End Message ---
--- Begin Message ---
On 11 October 2011 19:40, Nam Gi VU <nam.gi...@gmail.com> wrote:
> Hi every one,
> Currently when I call php --ini from CLI, I just see C:\Windows but search
> for this location, I cannot find any php.ini files.
> I'm stuck there - where is the php.ini file used by php.exe called from CLI
> as below
>
> *C:> php --ini*
The following documentation links are all relevant.
http://docs.php.net/manual/en/install.windows.manual.php
http://docs.php.net/manual/en/install.windows.commandline.php
http://docs.php.net/manual/en/configuration.file.php
--
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea
--- End Message ---
--- Begin Message ---
Hi folks,
Let's say that I have 2 constants
DEFINE('DESKTOP_URL_en', "http://www.website.com/index.php?page=home");
DEFINE('DESKTOP_URL_fr', "http://www.website.com/index.php?page=accueil");
and I would like to populate the value of an href with them depending
on the user's language. $_SESSION['lang'] is either 'en' or 'fr'.
How would I go about referring to this variable?
I have tried:
${'DESKTOP_URL_'.$_SESSION['lang']};
${DESKTOP_URL'.'_'.$_SESSION['lang']};
{DESKTOP_URL'.'_'.$_SESSION['lang']};
etc, to no avail.
If it is a regular variable I'm fine, it's the CONSTANT_FORMAT that
seems to be causing my brain some issues.
Thanks,
Marc
--- End Message ---