<?xml version="1.0" encoding="utf-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: How-to create a Password Generator using PHP</title>
	<atom:link href="http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/</link>
	<description>Web development tutorials, SEO articles and PHP script resources</description>
	<lastBuildDate>Tue, 09 Mar 2010 21:51:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Olaf</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120369</link>
		<dc:creator>Olaf</dc:creator>
		<pubDate>Thu, 26 Nov 2009 05:27:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120369</guid>
		<description>@srisoftwarez,
I remember me that I had some problems (years ago with notations like:

&lt;code&gt;$var ($is_true) ? &#039;cool&#039; : &#039;not cool&#039;;&lt;/code&gt;

But if you need to pass only one value to a variable , it should be fine to use these short notations. If I have 10 statements like this I can choose from 10 rows I need to scroll or 40</description>
		<content:encoded><![CDATA[<p>@srisoftwarez,<br />
I remember me that I had some problems (years ago with notations like:</p>
<p><code>$var ($is_true) ? 'cool' : 'not cool';</code></p>
<p>But if you need to pass only one value to a variable , it should be fine to use these short notations. If I have 10 statements like this I can choose from 10 rows I need to scroll or 40</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: srisoftwarez</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120368</link>
		<dc:creator>srisoftwarez</dc:creator>
		<pubDate>Thu, 26 Nov 2009 04:51:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120368</guid>
		<description>Hello Olaf,

      You are right. if we use the single row without using braces like &lt;b&gt;if ($use_numeric) $numbers = range(48, 57);&lt;/b&gt;
is very short. but the beginners can&#039;t able to understood it at first look.</description>
		<content:encoded><![CDATA[<p>Hello Olaf,</p>
<p>      You are right. if we use the single row without using braces like <b>if ($use_numeric) $numbers = range(48, 57);</b><br />
is very short. but the beginners can&#8217;t able to understood it at first look.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olaf</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120363</link>
		<dc:creator>Olaf</dc:creator>
		<pubDate>Wed, 25 Nov 2009 15:08:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120363</guid>
		<description>Hello Aziz,
you&#039;re right readability is important, but is also about personal &quot;coding style&quot; ;)
I see a lot of people coding this way:
&lt;pre lang=&quot;php&quot;&gt;
if ($val) 
{
    echo &#039;Hello!&#039;;
}
&lt;/pre&gt;

This is something I don&#039;t like.
Right my IF statement with a FOR loop on a single row without using braces is very short, but I can read this very well:
&lt;code&gt;if ($use_numeric) $numbers = range(48, 57);&lt;/code&gt;

btw. You see that Wordpress gives a new format to posted code as well.</description>
		<content:encoded><![CDATA[<p>Hello Aziz,<br />
you&#8217;re right readability is important, but is also about personal &#8220;coding style&#8221; <img src='http://www.web-development-blog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
I see a lot of people coding this way:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #009900;">&#41;</span> 
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Hello!'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is something I don&#8217;t like.<br />
Right my IF statement with a FOR loop on a single row without using braces is very short, but I can read this very well:<br />
<code>if ($use_numeric) $numbers = range(48, 57);</code></p>
<p>btw. You see that Wordpress gives a new format to posted code as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aziz Light</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120361</link>
		<dc:creator>Aziz Light</dc:creator>
		<pubDate>Wed, 25 Nov 2009 14:29:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120361</guid>
		<description>Sorry for the double post. In the line of code after &quot;but this is better:&quot; the line: &quot;$numbers = range(48, 57);&quot; should have been indented in my last comment...</description>
		<content:encoded><![CDATA[<p>Sorry for the double post. In the line of code after &#8220;but this is better:&#8221; the line: &#8220;$numbers = range(48, 57);&#8221; should have been indented in my last comment&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aziz Light</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120360</link>
		<dc:creator>Aziz Light</dc:creator>
		<pubDate>Wed, 25 Nov 2009 14:27:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120360</guid>
		<description>Nice script. Thanks

I have one concern with it (sorry, I&#039;m going to be a little bit blunt), but the syntax you use is atrocious and disgusting:

&lt;code&gt;if ($use_numeric) for ($nu = 48; $nu &lt;= 57; $nu++) $numbers[] = $nu;&lt;/code&gt;

This is acceptable though:

&lt;code&gt;if ($use_numeric) $numbers = range(48, 57);&lt;/code&gt;

but this is better:

&lt;code&gt;if ($use_numeric)
    $numbers = range(48, 57);&lt;/code&gt;

Code readability is very important...</description>
		<content:encoded><![CDATA[<p>Nice script. Thanks</p>
<p>I have one concern with it (sorry, I&#8217;m going to be a little bit blunt), but the syntax you use is atrocious and disgusting:</p>
<p><code>if ($use_numeric) for ($nu = 48; $nu < = 57; $nu++) $numbers[] = $nu;</code></p>
<p>This is acceptable though:</p>
<p></code><code>if ($use_numeric) $numbers = range(48, 57);</code></p>
<p>but this is better:</p>
<p><code>if ($use_numeric)<br />
    $numbers = range(48, 57);</code></p>
<p>Code readability is very important...</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olaf</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120268</link>
		<dc:creator>Olaf</dc:creator>
		<pubDate>Mon, 23 Nov 2009 12:29:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120268</guid>
		<description>Hi Jan,

Normally I use braces in my code, but for tutorials I try to keep the code as short as possible ... :)

I don&#039;t understand your second comment, do you suggest to use an array for the options? Why do you suggest a constant variable?
Try the &lt;a href=&quot;http://www.google.com/ig/adde?hl=en&amp;moduleurl=http://www.finalwebsites.com/password_generator.xml&amp;source=imag&quot; rel=&quot;nofollow&quot;&gt;Google gadget&lt;/a&gt; to see why I used multiple filters/switches as arguments.</description>
		<content:encoded><![CDATA[<p>Hi Jan,</p>
<p>Normally I use braces in my code, but for tutorials I try to keep the code as short as possible &#8230; <img src='http://www.web-development-blog.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I don&#8217;t understand your second comment, do you suggest to use an array for the options? Why do you suggest a constant variable?<br />
Try the <a href="http://www.google.com/ig/adde?hl=en&#038;moduleurl=http://www.finalwebsites.com/password_generator.xml&#038;source=imag" rel="nofollow">Google gadget</a> to see why I used multiple filters/switches as arguments.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan!</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120266</link>
		<dc:creator>Jan!</dc:creator>
		<pubDate>Mon, 23 Nov 2009 12:20:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120266</guid>
		<description>Thanks for sharing a code sample, but please don&#039;t teach people to use bad coding style. Omitting braces is a recipe for disaster here:

&lt;code&gt;if ($use_caps) for ($ca = 65; $ca &lt;= 90; $ca++) $caps[] = $ca; // create A-Z&lt;/code&gt;

Also, the way of specifying options can get awkward. A bit mask is more elegant here:

&lt;pre&gt;&lt;code&gt;function create_password($options) {
  if ($options &amp; PASSWORD_USE_SPECIALS) {
    /* ... */
  }
}&lt;/pre&gt;&lt;/code&gt;

And as said before, don&#039;t reinvent the wheel. :-)</description>
		<content:encoded><![CDATA[<p>Thanks for sharing a code sample, but please don&#8217;t teach people to use bad coding style. Omitting braces is a recipe for disaster here:</p>
<p><code>if ($use_caps) for ($ca = 65; $ca &lt;= 90; $ca++) $caps[] = $ca; // create A-Z</code></p>
<p>Also, the way of specifying options can get awkward. A bit mask is more elegant here:</p>
<pre><code>function create_password($options) {
  if ($options &amp; PASSWORD_USE_SPECIALS) {
    /* ... */
  }
}</code></pre>
<p>And as said before, don't reinvent the wheel. <img src='http://www.web-development-blog.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olaf</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120260</link>
		<dc:creator>Olaf</dc:creator>
		<pubDate>Mon, 23 Nov 2009 05:24:53 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120260</guid>
		<description>Hallo Tomek,

First of all thank for posting your code example.

&lt;h3&gt;Why not using PEAR?&lt;/h3&gt;
Sure your can download all classes from the pear site.
I think the best is the PEAR distribution system, why should I use PEAR? Because there are so many old projects? yes there are some good projects but how do I know as which are good? If I need to use some &quot;library&quot; I go for the Zend Framework. 

About your function, I used this kind of code very often (short and simple), but you see that my function has much more control about which character I can use. 

Don&#039;t forget this tutorial is supposed to show things work ;)</description>
		<content:encoded><![CDATA[<p>Hallo Tomek,</p>
<p>First of all thank for posting your code example.</p>
<h3>Why not using PEAR?</h3>
<p>Sure your can download all classes from the pear site.<br />
I think the best is the PEAR distribution system, why should I use PEAR? Because there are so many old projects? yes there are some good projects but how do I know as which are good? If I need to use some &#8220;library&#8221; I go for the Zend Framework. </p>
<p>About your function, I used this kind of code very often (short and simple), but you see that my function has much more control about which character I can use. </p>
<p>Don&#8217;t forget this tutorial is supposed to show things work <img src='http://www.web-development-blog.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120251</link>
		<dc:creator>Tomek</dc:creator>
		<pubDate>Sun, 22 Nov 2009 23:12:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120251</guid>
		<description>Correction of some errors I&#039;ve made:
- it should be &quot;strlen($specialSymbols) - 1&quot;
- $alphabet instead of $alhpabet in the 1st line of the function
- there is a &quot;&#039;&quot; repeated with the $alphabet declaration</description>
		<content:encoded><![CDATA[<p>Correction of some errors I&#8217;ve made:<br />
- it should be &#8220;strlen($specialSymbols) &#8211; 1&#8243;<br />
- $alphabet instead of $alhpabet in the 1st line of the function<br />
- there is a &#8220;&#8216;&#8221; repeated with the $alphabet declaration</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tomek</title>
		<link>http://www.web-development-blog.com/archives/how-to-create-a-password-generator-using-php/comment-page-1/#comment-120250</link>
		<dc:creator>Tomek</dc:creator>
		<pubDate>Sun, 22 Nov 2009 23:08:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.web-development-blog.com/?p=649#comment-120250</guid>
		<description>You don&#039;t have to have a hosting provider&#039;s permission to use PEAR packages (hint: they work without PEAR installer).
As for the code, how about something like this:
&lt;code&gt;
function randomString($length = 16)
{
    $alhpabet = &#039;&#039;ABCDEFGHIJKLMNOPORRQSTUWVXYZabcdefghijklmnoprqstuwvxyz0123456789!@#$%^&amp;*?&#039;;
    $alphabetLenght = strlen($alphabet) - 1;
    $string = &#039;&#039;;
    while($length) {
        $string .= $alphabet[mt_rand(0, $alphabetLenght)];
        --$length;
    }
    return $string;
}
&lt;/code&gt;

For a &quot;special symbols in 25% of the password&quot; thing you would have to have a separate variable for those special symbols and then in the loop something like this:
&lt;code&gt;
if (mt_rand(0,3)) {
    $string .= $alphabet[mt_rand(0, $alphabetLenght)];
} else {
    $string .= $specialSymbols[mt_rand(0, strlen($specialSymbols))];
}
&lt;/code&gt;
That won&#039;t guarantee you perfect 25% every time, but statistically it should oscillate around that number (gotta love math!) and it&#039;s much more elegant solution I think.</description>
		<content:encoded><![CDATA[<p>You don&#8217;t have to have a hosting provider&#8217;s permission to use PEAR packages (hint: they work without PEAR installer).<br />
As for the code, how about something like this:<br />
<code><br />
function randomString($length = 16)<br />
{<br />
    $alhpabet = ''ABCDEFGHIJKLMNOPORRQSTUWVXYZabcdefghijklmnoprqstuwvxyz0123456789!@#$%^&amp;*?';<br />
    $alphabetLenght = strlen($alphabet) - 1;<br />
    $string = '';<br />
    while($length) {<br />
        $string .= $alphabet[mt_rand(0, $alphabetLenght)];<br />
        --$length;<br />
    }<br />
    return $string;<br />
}<br />
</code></p>
<p>For a &#8220;special symbols in 25% of the password&#8221; thing you would have to have a separate variable for those special symbols and then in the loop something like this:<br />
<code><br />
if (mt_rand(0,3)) {<br />
    $string .= $alphabet[mt_rand(0, $alphabetLenght)];<br />
} else {<br />
    $string .= $specialSymbols[mt_rand(0, strlen($specialSymbols))];<br />
}<br />
</code><br />
That won&#8217;t guarantee you perfect 25% every time, but statistically it should oscillate around that number (gotta love math!) and it&#8217;s much more elegant solution I think.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
