I haven't looked at PHP for years and needed to read through
Sams' "Teach yourself PHP in 24 hours" recently.
Here are some basic tips for setting things up:
1. Assuming your Apache server allows you to use .htaccess
files, you can set a bunch of useful stuff here, eg:
AddType application/x-httpd-php .php
For instance, if most of your site is real .html files
but you want to put .php files in a certain folder,
you can put an .htaccess file in that folder that tells
Apache to run the php interpreter on .html files in
that folder:
AddType application/x-httpd-php .html
(You don't want to do that in your root folder because it
would waste time running the php interpreter on all the
ordinary html files.)
2. The phpinfo() command inside php of course produces
a nicely-formatted html file with all the setup information
for php, and you need to look at it. In particular, you
want to check which php version you have and what modules
are loaded (irritatingly Panix has a rather old version
with few modules compiled in).
Also, it's good to check the "config-file-path". This
(assuming you have shell access) allows you to find the
actual php.ini file to check any items not shown by
the phpinfo() command.
3. If you don't control the server, you can still set
php setup variables inside .htaccess. You use the "php_flag"
directive to set a php variable and the php_value directive
to set a php.ini variable to a value, eg:
php_flag short_open_tag On
php_value include_path ".:/home/corrdev"
4. Even if you can't use .htaccess files, as of php 4.0.5
you can set some .ini values within php pre itself, eg:
ini_set( "include_path", ".:/home/corrdev" );
5. Don't forget the main php website, eg:
www.php.net
[http://www.php.net/manual]
6. Here's the entire contents of a file you can save as
test.php:
<?php
phpinfo();
?>
(I know putting that here makes me look like not the greatest
programmer in the world, but every time I start looking at
php again I find myself having to work out the basics of the
syntax all over again.)
7. Here's some code which looks simple – ok, it is simple –
but I find myself wondering whether it will work every time
I start playing with php again (this is basically from the
book's Listing 5.14 Returning to HTML Mode within a pre
block):
<?php
$display_prices= true;
if ( $display_prices ) {
?>
<p>Interesting stuff to show in this case</p>
<?php
}
?>
I don't know about you, but if I had to figure out that syntax from
scratch it would take a while.
Link to PHP manual
I have downloaded a PHP manual in HTML form, but when I saw a link to PHP
docs I thought I should add a link to my site.
www.php.net
[http://www.php.net/download-docs.php]
Note that this version presumably provides you with docs for the *current*
(latest) version. Many people are still working with some rev of v4
(as this is what is provided by hosting sites, and is the version for
which most sample code is available) and I don't see how to find docs
for that.
I hope this information was useful. There may be a great deal more
information on this site that is relevant to what you need.
Take
a look at the "site map" display at left; you
can click on a topic to see many recent items on that topic.
Debug: hittotal: 9 startban: 0
dancookie: endbandate:
banned: 0 tempdate:
tert: jse: jsno jsh: 9