<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=190.27.10.162</id>
		<title>FreeBSDwiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=190.27.10.162"/>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/Special:Contributions/190.27.10.162"/>
		<updated>2026-05-03T09:34:23Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://freebsdwiki.net/index.php/PHP</id>
		<title>PHP</title>
		<link rel="alternate" type="text/html" href="http://freebsdwiki.net/index.php/PHP"/>
				<updated>2009-10-22T23:14:07Z</updated>
		
		<summary type="html">&lt;p&gt;190.27.10.162: /* Installing PHP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;PHP is a recursive acronym for ''PHP Hypertext Preprocessor''. It is an interpreted script language commonly used for dynamic pages generation on webservers. It is generally installed side by side with the [[Apache]] web server, and [[MySQL]] or [[PostgreSQL]] as database management system.&lt;br /&gt;
&lt;br /&gt;
Customs officer for examination. ,&lt;br /&gt;
&lt;br /&gt;
==Using PHP==&lt;br /&gt;
There are two ways to use PHP :&lt;br /&gt;
* With apache: configure apache to use php to process .php files requested by the user.&lt;br /&gt;
* As a command interpreter: php can process scripts, or instructions typed at the commandline.&lt;br /&gt;
&lt;br /&gt;
===PHP for dynamic websites===&lt;br /&gt;
&lt;br /&gt;
All the steps of Apache configuration are explained after PHP installation. You have to add these two lines in httpd.conf:&lt;br /&gt;
 AddType application/x-httpd-php .php&lt;br /&gt;
 AddType application/x-httpd-php-source .phps&lt;br /&gt;
&lt;br /&gt;
You will probably also want to add ''index.php'' as a possible directory index:&lt;br /&gt;
 DirectoryIndex index.html index.php&lt;br /&gt;
&lt;br /&gt;
You have to restart Apache to have your changes effective. For example, if you use Apache 2:&lt;br /&gt;
 /usr/local/etc/rc.d/apache2.sh restart&lt;br /&gt;
&lt;br /&gt;
Now, you can try your installation by creating a file test.php in the /usr/local/www/data directory:&lt;br /&gt;
 &amp;lt;?&lt;br /&gt;
    phpinfo();&lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Request test.php using your web browser, and if all is well it will show you your PHP configuration.&lt;br /&gt;
&lt;br /&gt;
===Scripts in PHP===&lt;br /&gt;
&lt;br /&gt;
If you have compiled PHP with the commandline interface, you can write scripts in PHP that can be used from the [[shell]]. This is very useful for ''quick and dirty'' hacks; especially if you want your output to be HTML. Put the PHP code in a file like this :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 #!/usr/local/bin/php&lt;br /&gt;
 # phpscript&lt;br /&gt;
 &amp;amp;lt;html&amp;amp;gt; &amp;amp;lt;title&amp;amp;gt;Defined Constants&amp;amp;lt;/title&amp;amp;gt; &amp;amp;lt;body&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;h1&amp;amp;gt;&amp;amp;lt;? echo &amp;quot;Hello from PHP &amp;quot; .phpversion() ?&amp;amp;gt;&amp;amp;lt;/h1&amp;amp;gt;&lt;br /&gt;
 &amp;amp;lt;pre&amp;amp;gt;&amp;amp;lt;? print_r(get_defined_constants()) ?&amp;amp;gt;&amp;amp;lt;/pre&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &amp;amp;lt;/body&amp;amp;gt;&amp;amp;lt;/html&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make the file executable:&lt;br /&gt;
 '''%''' chmod +x phpscript&lt;br /&gt;
&lt;br /&gt;
Then, you can run it from the command line.&lt;br /&gt;
&lt;br /&gt;
 '''%''' ./phpscript | lynx -stdin&lt;br /&gt;
In this case, we've piped to &amp;lt;code&amp;gt;lynx&amp;lt;/code&amp;gt;, so that we can browse the nicely formatted result.&lt;br /&gt;
&amp;lt;pre style=&amp;quot;background-color:black; color:white&amp;quot;&amp;gt;&lt;br /&gt;
                                              Defined Constants (p1 of 154)&lt;br /&gt;
&lt;br /&gt;
                             Hello from PHP 5.1.4&lt;br /&gt;
&lt;br /&gt;
 Array&lt;br /&gt;
 (&lt;br /&gt;
    [E_ERROR] =&amp;gt; 1&lt;br /&gt;
    [E_WARNING] =&amp;gt; 2&lt;br /&gt;
    [E_PARSE] =&amp;gt; 4&lt;br /&gt;
    [E_NOTICE] =&amp;gt; 8&lt;br /&gt;
 -- press space for more, use arrow keys to move, '?' for help, 'q' to quit.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Or, we could have executed the command directly from the command line:&lt;br /&gt;
 '''%''' php -r 'echo &amp;quot;Hello from PHP &amp;quot;. phpversion() . &amp;quot;\n&amp;quot;; print_r(get_defined_constants());'&lt;br /&gt;
 Hello from PHP 5.1.4 &lt;br /&gt;
 Array&lt;br /&gt;
 (&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
==PHP Website==&lt;br /&gt;
[http://www.php.net http://www.php.net]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category: Ports and Packages]]&lt;br /&gt;
[[Category: Configuring FreeBSD]]&lt;/div&gt;</summary>
		<author><name>190.27.10.162</name></author>	</entry>

	</feed>