LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Nathan Wallace Date: Wed Aug 11 00:58:32 1999 Subject: PHP Knowledge Base Update -- August 10th, 1999
This is another reminder that anyone can contribute to the knowledge
base. Editing an entry is simple, just follow the link and click on
Edit in the top right hand corner. Your name will be added to the list
of contributors for that question.
You can also add new entries. They don't have to be perfect. I work
under the assumption that something is better than nothing and someone
will fix it eventually anyway...
For more information on how you can help, see:
http://e-gineer.com/e-gineer/phpkb/contribute.phtml
Cheers,
Nathan
------------------------------------------------------------
How can I improve the performance of my very large site?
I have a lot of include()'d code, how can I improve performance?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/572
------------------------------------------------------------
Jacob Stetser
Try using _conditional includes_ and only include what you need for
any particular page. I did this and speeded up a script of mine that
was running into about 2-3,000 lines of code.. it was usually running
between 1-4 seconds per page, and now it runs between .1-.9 sec per
page. I instituted a caching system and pages that are cached take
about 2-3 THOUSANDTHS of a second per page PHP execution time! (I
still use PHP to determine whether to serve a cached page or a real
page, but the script is only about 150 lines total before I call an
exit(); if it serves a cached page.
I don't have any real world testing of how this affects server load,
but I have a feeling that PHP does better the less code you give it
at a time, and that caching pages, if it can be done, can make
a script incredibly light when it comes to server load.
Example of conditional include
if($action=="buystock") {
include("./includes/buystock.inc");
} elseif(....) {
include("....");
} etc...
------------------------------------------------------------
How can I move a file?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/574
------------------------------------------------------------
Teodor Cimpoesu
rename() should do that:
http://www.php.net/manual/function.rename.php3
------------------------------------------------------------
How can I write a script that will read a mail message?
How can I invoke a script when an email is received?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/575
------------------------------------------------------------
Chris Adams
You can set a .forward or a sendmail alias to execute a script (Use
"|/path/to/my/script.pl" instead of an address). You can either write a
script to use the CGI version of PHP or use something like Perl to
insert it into the same database (which is probably more portable).
------------------------------------------------------------
How can I select rows within a certain date range?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/577
------------------------------------------------------------
Jason Brooke
It depends on how you're storing your dates, but the following should
give you some ideas:
select messagefield
from tablename
where datefield between $startdate and $enddate
or:
select messagefield
from tablename
where datefield >= $startdate and datefield <= $enddate
or:
select messagefield
from tablename
where datefield > $startdate and datefield < $enddate
(same as second one but adjust $startdate and $enddate to be just
outside the boundaries you seek - might help make sql faster, dunno)
------------------------------------------------------------
How can I connect to MS-SQL from a Linux box?
How can I connect to ODBC datasources on a Win NT machine from
a Linux box?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/578
------------------------------------------------------------
Matt Corddry
I'm currently connecting to an ms-sql7 machine from a linux box. I'm
using the openlink multitier odbc drivers, which work well. Their
webpage is @ http://www.openlinksw.com/. You can then compile php3 with
openlink support, and create an odbc.ini file in the openlink directory
which references your database server. Works well & seems to be solid
under load. There's a good howto on this exact topic at:
http://www.silen.net/openlink-php-odbc.txt
Another alternative is an odbc-odbc bridge by easysoft
(http://beta.easysoft.com). It's pretty straightforward, and actually
faster in my tests than the openlink solution. However, the NT gateway
daemon leaks memory under load, so I really can't recommend it for
production.
** OTHER RANDOMLY SELECTED PHPKB ENTRIES **
------------------------------------------------------------
Does PHP support C-syntax if statements without braces?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/459
------------------------------------------------------------
if(condition) statement; else statement;
works fine in PHP.
------------------------------------------------------------
Do I need to put CR and LF after HTTP protocol elements?
Do HEAD and GET HTTP requests require a CR and an LF?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/292
------------------------------------------------------------
HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
protocol elements except the entity-body (see appendix 19.3 for
tolerant applications).
(19.3 recommends that applications recognize a single LF.)
So the answer should be "always use \r\n". Any HTTP/1.1 server that
doesn't accept it violates the standard.
(Essentially the same text appears in the HTTP/1.0 spec.)
So the following may not work as expected:
fputs($sock,"HEAD / HTTP/1.0\n");
You should use \r\n instead:
fputs($sock,"HEAD / HTTP/1.0\r\n");
If you do not use \r\n then the HTTP server may not recognise the
request and your script will wait for the request to the server to
timeout. This may give the appearance of hanging if the HTTP server
does not handle timeouts properly.
------------------------------------------------------------
How can I pass variables to a script in the url like /script/var1/var2?
How can I pass variables in a form that won't scare off search engines?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/142
------------------------------------------------------------
It's easy. Just use:
/local.php3/var1/var2
Then in your PHP code parse the url and extract the variables. This
works since Apache finds the local.php3 script and ignores the rest of
the url.
For example:
http://www.server.com/page.html/wilma/betty
and then in the script:
$res = explode("page.html/", $REQUEST_URI);
$vars = explode("/", $res[1]);
$fred = vars[0];
$barney = vars[1];
If you want to get rid of the ugly .php3 in the middle of your url take
a look at the Apache ForceType directive.
http://www.apache.org/docs/mod/mod_mime.html#forcetype
------------------------------------------------------------
How can I make a PHP script be called from the cron daemon?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/92
------------------------------------------------------------
Compile PHP as CGI (ie, leave off --with-apache or --with-apxs and keep
all the other compile switches the same).
Then, simply add a line to your cron file using crontab -e (see man 5
crontab) like usual.
Don't forget to call php with the -q option to suppress HTTP headers.
Alternatively, if you have access to lynx you can leave PHP alone and
put the following into your crontab.
lynx -dump http://www.myhost.com/myscript.phtml
crontab mails you the results of the script automatically. You can
suppress this mail from being sent by redirecting the output to a file:
lynx -dump http://www.myhost.com/myscript.phtml >somefile.html
------------------------------------------------------------
What is the maximum length of a URL string?
What is the longest URL that Apache can handle?
Is there a maximum number of GET arguments that can be used?
http://e-gineer.com/e-gineer/phpkb/view.phtml/qid/476
------------------------------------------------------------
There is theoretically no limit. The HTTP spec doesn't specify, so it
will vary from server to server (possibly browser to browser as well).
Someone reported a while ago that apache could handle something like up
to 8k...
Well, I *think* there was a 256 character limit on some browser. (Read
that in some HTML book :)
Could've been lifted by now, but if it's more then 256 characters you're
better off with cookies or POSTing the data anyway.
| Navigate in group php.kb at sever news.php.net | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by Zareef Ahmed
Powered By PHP Consultants |