<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ask Your Question &#187; PHP</title>
	<atom:link href="http://askbahar.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://askbahar.com</link>
	<description>Lets Talk</description>
	<lastBuildDate>Fri, 30 Jul 2010 04:34:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>What is the difference between this &amp; this(), super &amp; super()</title>
		<link>http://askbahar.com/2010/07/30/difference-this-super/</link>
		<comments>http://askbahar.com/2010/07/30/difference-this-super/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 04:34:41 +0000</pubDate>
		<dc:creator>Habib Ullah Bahar</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Object Oriented Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[super]]></category>
		<category><![CDATA[this]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://askbahar.com/?p=73</guid>
		<description><![CDATA[Well the topic is a basic in OOP, when I first learned my first OO language (C++ back in 2004), I have learned the basic. Few days ago some one asked the question, suddenly I become confused, so I made a quick research, and decided to post this and super both are object. this() and]]></description>
			<content:encoded><![CDATA[<p>Well the topic is a basic in OOP, when I first learned my first OO language (C++ back in 2004), I have learned the basic. Few days ago some one asked the question, suddenly I become confused, so I made a quick research, and decided to post <img src='http://askbahar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>this </strong>and <strong>super </strong>both are object. <strong>this() </strong>and <strong>super() </strong>both are constructors.</p>
<p><strong>this </strong>is the object of current class.</p>
<p><strong>this() </strong>is the constructor of current class.</p>
<p><strong>super </strong>is the object of parent class.</p>
<p><strong>super()</strong> is the constructor of parent class.</p>
<p><strong>Example (</strong><em>in java) </em>please check out this nice example provided in <a title="Java Constructors" href="http://leepoint.net/notes-java/oop/constructors/constructor.html" target="_self">this link</a></p>
<p>I hope this will save someone&#8217;s day <img src='http://askbahar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://askbahar.com/2010/07/30/difference-this-super/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to generate getter/setter in PHP easily</title>
		<link>http://askbahar.com/2010/07/14/generate-getter-setter-in-php-easily/</link>
		<comments>http://askbahar.com/2010/07/14/generate-getter-setter-in-php-easily/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:21:16 +0000</pubDate>
		<dc:creator>Habib Ullah Bahar</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[get-set]]></category>

		<guid isPermaLink="false">http://askbahar.com/?p=70</guid>
		<description><![CDATA[For one of my current project I need to write getter/setter functions for 20+ variables. You know, how annoying it is! Well, I can use magic quotes, but I don&#8217;t like it. More over getter setter will help you later to use the class when your IDE (in my case Netbeans) supports auto complete suggestion.]]></description>
			<content:encoded><![CDATA[<p>For one of my current project I need to write getter/setter functions for 20+ variables. You know, how annoying it is! Well, I can use magic quotes, but I don&#8217;t like it. More over getter setter will help you later to use the class when your IDE (in my case <a title="Netbeans IDE" href="http://netbeans.org" target="_self">Netbeans</a>) supports <em>auto complete suggestion</em>. Though all Java development environments allow to generate getter and  setter code automatically.<br />
Then I started coding a php script for generating getter/setter for supplied variables, but I was lucky as suddenly I thought &#8220;why don&#8217;t I look for something like this online&#8221; <img src='http://askbahar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>And here is the link I got, its quite good. <a title="PHP Getter Setter Generator" href="http://www.icurtain.co.uk/getset.php" target="_blank">http://www.icurtain.co.uk/getset.php</a>, It saved my time.</p>
]]></content:encoded>
			<wfw:commentRss>http://askbahar.com/2010/07/14/generate-getter-setter-in-php-easily/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>World City locations database</title>
		<link>http://askbahar.com/2010/07/02/world-city-locations-database/</link>
		<comments>http://askbahar.com/2010/07/02/world-city-locations-database/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 05:39:06 +0000</pubDate>
		<dc:creator>Habib Ullah Bahar</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[world altitude]]></category>
		<category><![CDATA[world cities]]></category>
		<category><![CDATA[world countries]]></category>
		<category><![CDATA[world latitude]]></category>
		<category><![CDATA[world locations]]></category>
		<category><![CDATA[world longitude]]></category>

		<guid isPermaLink="false">http://askbahar.com/?p=61</guid>
		<description><![CDATA[For one of my projects, I need the geographical location (latitude, longitude, altitude) of all main cities of the world. It was a adobe air project to determine worldwide salat timetable automatically. I couldn&#8217;t find a complete list. Then I found this site, Aneki World Cities. Then I designed a scrapper using PHP, and scrapped]]></description>
			<content:encoded><![CDATA[<p>For one of my projects, I need the geographical location (latitude, longitude, altitude) of all main cities of the world. It was a <a title="Waqt Al Salat Desktop (beta version)" href="http://d.mobilewaqt.com/">adobe air project</a> to determine worldwide salat timetable automatically.</p>
<p>I couldn&#8217;t find a complete list. Then I found this site, <a title="World Cities" href="http://www.aneki.com/cities.html" target="_self"><em>Aneki World Cities.</em></a> Then I designed a scrapper using PHP, and scrapped all the countries first, then their respective cities list, then respective geographical location. Then end result was a table in the database with all countries, respective cities and locations <img src='http://askbahar.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-61"></span></p>
<p>As I have only compiled the database, the information aren&#8217;t mine, so I have decided to make the table publicly available. You can download the zip file here: <a title="World Cities Locations" href="http://dl.dropbox.com/u/2495616/World_Cities_Location_table.zip" target="_self">World Cities Locations</a> <em>(The zip file contains 4 types of file for same content. SQL, CSV, CSV for MS EXCEL, MS EXCEL 2000. All of them are exported from MySQL using phpMyAdmin)</em></p>
<p>The sql file contains the schema to reproduce the <em><strong>location </strong></em>table in your designated database (assuming you are using mysql database engine. If you aren&#8217;t, you can easily convert the sql schema <img src='http://askbahar.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> ).</p>
<p>The table has in 10,567 rows (means 10,567 unique cities, their locations and 170 countries).</p>
<p>The table has 5 fields, <strong><em>id, country, city, latitude, longitude, altitude</em></strong>. From their name, I hope you can understand their significance.</p>
<p>The table can be used in different ways:</p>
<ul>
<li>Getting all countries of the world (170 countries):<code class="syntax sql"> SELECT DISTINCT(country) FROM location</code></li>
<li>Getting all cities of a country:<code class="syntax sql"> SELECT city FROM location WHERE country = 'YOUR_COUNTRY_NAME_HERE'</code></li>
<li>Getting the location of a specific city of a specific country:<br />
<code class="syntax sql">SELECT latitude,longitude,altitude FROM location WHERE country='COUNTRY_NAME' AND city = 'CITY_NAME'</code></li>
</ul>
<p>I hope this small contribution to the open world helps all. You can use the content in location based applications, finding a city easily in map services etc.<em> </em></p>
<p><em> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://askbahar.com/2010/07/02/world-city-locations-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to enable Apache HTTP Authentication using PHP</title>
		<link>http://askbahar.com/2009/11/11/enable-apache-http-authentication-using-php/</link>
		<comments>http://askbahar.com/2009/11/11/enable-apache-http-authentication-using-php/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 09:24:39 +0000</pubDate>
		<dc:creator>Habib Ullah Bahar</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Authentication]]></category>

		<guid isPermaLink="false">http://askbahar.com/?p=48</guid>
		<description><![CDATA[The easiest way to password-protect a site is to use HTTP Authentication, where if a browser’s request for a protected page is not accompanied by the correct username and password, the Web server replies with an HTTP 401 error – which means “Unauthorized Access” – and an invitation for the browser to re-submit the request]]></description>
			<content:encoded><![CDATA[<p>The easiest way to password-protect a site is to use HTTP Authentication, where if a browser’s request for a protected page is not accompanied by the correct username and password, the Web server replies with an HTTP 401 error – which means “Unauthorized Access” – and an invitation for the browser to re-submit the request with a proper username and password. From the user’s point of view, most of this dialogue is hidden. Following that first failed request, the browser prompts the user (in a dialog box) for a username and password, and then re-submits the request, this time with the authentication information attached. Assuming the username/password combo is on the list of allowed users, the Web server then sends the page requested. The Web browser will likewise continue to send that username/password with all subsequent requests.</p>
<p>Look at the following code:<br />
<span id="more-48"></span></p>
<pre>
<code>
<?php
/*
    Document   : auth
    Created on : Nov 11, 2009, 9:08:32 AM
    @author    : Bahar
    Email      : bahar@progmaatic.com
    Copyright  : http://progmaatic.com

    Description: Authenticate user
*/

require_once 'settings.php';

$failure_msg = " <HTML>
 <HEAD><TITLE>Authorization Failed</TITLE></HEAD>
 <BODY>
 <H1>Authorization Failed</H1>
 <P>Without a valid username and password,
    access to this page cannot be granted.
    Please click 'reload' and enter a
    username and password when prompted.
 </P>
 </BODY>
 </HTML>";

if (!isset($_SERVER['PHP_AUTH_USER']) || $_SERVER['PHP_AUTH_USER']!==$site_user || $_SERVER['PHP_AUTH_PW']!==$site_pass)
   {
       header("WWW-Authenticate: Basic realm=\"Protected Page: Enter your username and password for access.\"");
       header("HTTP/1.0 401 Unauthorized");
       exit($failure_msg);
   }

?>
</code>
</pre>
<p>For each page, you want to authenticate user, each page must have the above code. You can save this code to a script (for example <em>auth.php</em>) and include <em>auth.php</em> to any page, hence save yourself from rewriting the code for each page.</p>
]]></content:encoded>
			<wfw:commentRss>http://askbahar.com/2009/11/11/enable-apache-http-authentication-using-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
