<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5053895600113828356</id><updated>2012-02-16T03:58:00.272-08:00</updated><category term='url'/><category term='Tips'/><category term='superglobal'/><title type='text'>PHP Knowledge Base</title><subtitle type='html'>Knowledge Base on PHP scripting. Help you in PHP Programming, get valuable PHP information and PHP tips from PHP script collection available in this blog!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phpkb.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phpkb.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>FreeForBiz</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5053895600113828356.post-5969841870080907209</id><published>2007-12-18T04:59:00.000-08:00</published><updated>2007-12-18T05:35:21.862-08:00</updated><title type='text'>PHP Code View Highlighter</title><content type='html'>This uses php's &lt;code&gt;highlight_string()&lt;/code&gt; function to highlight your php code.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;title&lt;/span&gt;&amp;gt;Color Coder&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;/title&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 102, 255);"&gt;if&lt;/span&gt;( &lt;span style="color: rgb(51, 102, 255);"&gt;isset&lt;/span&gt;( &lt;span style="color: rgb(0, 0, 153);"&gt;$_POST&lt;/span&gt;[&lt;span style="color: rgb(51, 204, 0);"&gt;'content'&lt;/span&gt;] ) )&lt;br /&gt;{&lt;br /&gt;   &lt;span style="color: rgb(0, 0, 153);"&gt;$php_code&lt;/span&gt; = highlight_string( &lt;span style="color: rgb(51, 102, 255);"&gt;stripslashes&lt;/span&gt;( &lt;span style="color: rgb(0, 0, 153);"&gt;$_POST&lt;/span&gt;[&lt;span style="color: rgb(51, 204, 0);"&gt;'content'&lt;/span&gt;] ), true );&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;div &lt;/span&gt;style=&lt;span style="color: rgb(51, 204, 0);"&gt;"background:#FFFFCC; border:2px solid #999999; width:550px;"&lt;/span&gt;&amp;gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;&amp;lt;!-- Start Code --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&amp;lt;?php&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;$php_code&lt;/span&gt; . &lt;span style="color: rgb(51, 204, 0);"&gt;"\n"&lt;/span&gt;; &lt;span style="color: rgb(255, 0, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 153, 153);"&gt;&amp;lt;!-- End Code --&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;/div&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;br&lt;/span&gt; /&amp;gt;&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&amp;lt;?php&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;&lt;span style="color: rgb(255, 0, 0);"&gt;?&amp;gt;&lt;/span&gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;form &lt;/span&gt;method=&lt;span style="color: rgb(51, 204, 0);"&gt;"post"&lt;/span&gt; action=&lt;span style="color: rgb(51, 204, 0);"&gt;""&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;textarea &lt;/span&gt;name=&lt;span style="color: rgb(51, 204, 0);"&gt;"content"&lt;/span&gt; rows=&lt;span style="color: rgb(51, 204, 0);"&gt;"15"&lt;/span&gt; cols=&lt;span style="color: rgb(51, 204, 0);"&gt;"45"&lt;/span&gt;&amp;gt;&lt;span style="color: rgb(255, 0, 0);"&gt;&amp;lt;?php&lt;/span&gt; &lt;span style="color: rgb(51, 102, 255);"&gt;echo stripslashes&lt;/span&gt;( &lt;span style="color: rgb(0, 0, 153);"&gt;$_POST&lt;/span&gt;[&lt;span style="color: rgb(51, 204, 0);"&gt;'content'&lt;/span&gt;] ); &lt;span style="color: rgb(255, 0, 0);"&gt;?&amp;gt;&lt;/span&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;/textarea&lt;/span&gt;&amp;gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;br &lt;/span&gt;/&amp;gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;input &lt;/span&gt;type=&lt;span style="color: rgb(51, 204, 0);"&gt;"submit"&lt;/span&gt; value=&lt;span style="color: rgb(51, 204, 0);"&gt;"Color Me!"&lt;/span&gt; /&amp;gt;&lt;br /&gt;&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;/form&lt;/span&gt;&amp;gt;&lt;br /&gt;Just type in your &amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;strong&lt;/span&gt;&amp;gt;PHP&amp;lt;&lt;span style="color: rgb(255, 102, 0);"&gt;/strong&lt;/span&gt;&amp;gt; code that you would like to be color coded&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5053895600113828356-5969841870080907209?l=phpkb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpkb.blogspot.com/feeds/5969841870080907209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5053895600113828356&amp;postID=5969841870080907209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/5969841870080907209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/5969841870080907209'/><link rel='alternate' type='text/html' href='http://phpkb.blogspot.com/2007/12/php-code-view-highlighter.html' title='PHP Code View Highlighter'/><author><name>FreeForBiz</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5053895600113828356.post-1595225527842344140</id><published>2007-12-14T22:55:00.000-08:00</published><updated>2007-12-14T23:54:27.401-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips'/><title type='text'>Use other extension for PHP scripts</title><content type='html'>To be able to use php scripts on a page with an extension other than default &lt;span style="font-weight: bold;"&gt;.php&lt;/span&gt;, you need a server which supports creating/editing &lt;span style="font-weight: bold;"&gt;.htaccess&lt;/span&gt; files.&lt;br /&gt;&lt;br /&gt;To add an extension to be parsed for php, create or edit a file called .htaccess (&lt;span style="color: rgb(204, 0, 0);"&gt;with the dot first&lt;/span&gt;) containing the following line:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;AddType application/x-httpd-php .html .foo .htm&lt;/code&gt;&lt;/blockquote&gt;This tells the server to check for php code and execute it in files with extensions .html, .foo or .htm. So upload that .htaccess file in the same folder as your .html files with PHP code inside them (using PHP tags: &lt;code&gt;&amp;lt;?php&lt;/code&gt; ... &lt;code&gt;?&amp;gt;&lt;/code&gt;) then when you view them in the browser, the PHP should be dealt with as you’d expect from a PHP page.&lt;br /&gt;&lt;br /&gt;Another way is by using mod rewrite (here is an &lt;a href="http://www.workingwith.me.uk/articles/scripting/mod_rewrite"&gt;excellent tutorial about mod rewrite&lt;/a&gt;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5053895600113828356-1595225527842344140?l=phpkb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpkb.blogspot.com/feeds/1595225527842344140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5053895600113828356&amp;postID=1595225527842344140' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/1595225527842344140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/1595225527842344140'/><link rel='alternate' type='text/html' href='http://phpkb.blogspot.com/2007/12/use-other-extension-for-php-scripts.html' title='Use other extension for PHP scripts'/><author><name>FreeForBiz</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5053895600113828356.post-5453389864993914634</id><published>2007-12-14T22:25:00.000-08:00</published><updated>2007-12-14T22:52:52.493-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='url'/><category scheme='http://www.blogger.com/atom/ns#' term='superglobal'/><title type='text'>Find the Current URL</title><content type='html'>The &lt;span style="font-weight: bold;"&gt;full URL&lt;/span&gt; to a web page comes in four parts: The &lt;span style="font-weight: bold;"&gt;protocol&lt;/span&gt;&lt;span&gt; prefix, the &lt;/span&gt;&lt;span style="font-weight: bold;"&gt;domain name&lt;/span&gt;, the &lt;span style="font-weight: bold;"&gt;path to the file&lt;/span&gt; and the &lt;span style="font-weight: bold;"&gt;filename&lt;/span&gt;, and the &lt;span style="font-weight: bold;"&gt;query string&lt;/span&gt;. For example, take the URL &lt;code&gt;http://www.example.com/example/page.php?name=Bob&lt;/code&gt;. The three parts of this are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;The domain name: &lt;code&gt;www.example.com&lt;/code&gt;&lt;/li&gt;&lt;li&gt;The path to the page: &lt;code&gt;/example/page.php&lt;/code&gt;&lt;/li&gt;&lt;li&gt;The query string: &lt;code&gt;name=Bob&lt;/code&gt;&lt;/li&gt;&lt;/ol&gt;Here we will show do you how to find current URL with your own PHP scripts...&lt;br /&gt;&lt;br /&gt;All of the information we need is stored in the &lt;span style="font-weight: bold;"&gt;&lt;code&gt;$_SERVER&lt;/code&gt;&lt;/span&gt; array, which is accessible from anywhere in your PHP script (and as such is called a superglobal variable), it works like a normal array and the keys we wish to retrieve the values of are &lt;span style="color: rgb(0, 102, 0);"&gt;'HTTPS'&lt;/span&gt;, &lt;span style="color: rgb(0, 102, 0);"&gt;'HTTP_HOST'&lt;/span&gt;, &lt;span style="color: rgb(0, 102, 0);"&gt;'SCRIPT_NAME'&lt;/span&gt; and &lt;span style="color: rgb(0, 102, 0);"&gt;'QUERY_STRING'&lt;/span&gt; for the four different parts of the url. Alternatively, if we don't need to have the path to the page and the query string seperate, we can use &lt;span style="color: rgb(0, 102, 0);"&gt;'REQUEST_URI'&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;The following code should let you find it:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//find out the protocol&lt;/span&gt;&lt;br /&gt;$protocol = ($_SERVER[&lt;span style="color: rgb(0, 102, 0);"&gt;'HTTPS'&lt;/span&gt;] ? &lt;span style="color: rgb(0, 102, 0);"&gt;'https://'&lt;/span&gt; : &lt;span style="color: rgb(0, 102, 0);"&gt;'http://'&lt;/span&gt;);&lt;br /&gt;&lt;/code&gt;&lt;code&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//find out the domain&lt;/span&gt;&lt;br /&gt;$domain = $_SERVER[&lt;span style="color: rgb(0, 102, 0);"&gt;'HTTP_HOST'&lt;/span&gt;];&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//find out the path to the current file:&lt;/span&gt;&lt;br /&gt;$path = $_SERVER[&lt;span style="color: rgb(0, 102, 0);"&gt;'SCRIPT_NAME'&lt;/span&gt;];&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//find out the QueryString:&lt;/span&gt;&lt;br /&gt;$queryString = $_SERVER[&lt;span style="color: rgb(0, 102, 0);"&gt;'QUERY_STRING'&lt;/span&gt;];&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//put it all together...&lt;/span&gt;&lt;br /&gt;$url = $protocol . $domain . $path . &lt;span style="color: rgb(0, 102, 0);"&gt;"?"&lt;/span&gt; . $queryString;&lt;br /&gt;echo &lt;span style="color: rgb(0, 102, 0);"&gt;"The current URL is: "&lt;/span&gt; . $url;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//An alternative way is to use REQUEST_URI instead of&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 153, 153);"&gt;//both SCRIPT_NAME and QUERY_STRING:&lt;/span&gt;&lt;br /&gt;$url2 = &lt;span style="color: rgb(0, 102, 0);"&gt;&lt;/span&gt;$protocol . $domain . $_SERVER[&lt;span style="color: rgb(0, 102, 0);"&gt;'REQUEST_URI'&lt;/span&gt;];&lt;br /&gt;&lt;br /&gt;echo &lt;span style="color: rgb(0, 102, 0);"&gt;"The alternative way: "&lt;/span&gt; . $url2;&lt;/code&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5053895600113828356-5453389864993914634?l=phpkb.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpkb.blogspot.com/feeds/5453389864993914634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5053895600113828356&amp;postID=5453389864993914634' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/5453389864993914634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5053895600113828356/posts/default/5453389864993914634'/><link rel='alternate' type='text/html' href='http://phpkb.blogspot.com/2007/12/find-current-url.html' title='Find the Current URL'/><author><name>FreeForBiz</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
