<?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>PHP IDE</title>
	<atom:link href="http://www.phpide.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpide.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Mon, 05 Sep 2011 12:01:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>PHP on Page Validation Form</title>
		<link>http://www.phpide.com/php-tutorials/php-on-page-validation-form/</link>
		<comments>http://www.phpide.com/php-tutorials/php-on-page-validation-form/#comments</comments>
		<pubDate>Sun, 04 Sep 2011 19:10:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[html validation form]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[php tutorial for beginners]]></category>
		<category><![CDATA[php tutorials]]></category>
		<category><![CDATA[php validation form]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=390</guid>
		<description><![CDATA[You may have encounter website page types were should the user would make a error in filling the kind the error message would be shown (commonly in red) just previously mentioned the actual type command (area). I exhibit you the way to do this with PHP in this post. Case in point HTML Kind We [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>You may have encounter website page types were should the user would make a error in filling the kind the error message would be shown (commonly in red) just previously mentioned the actual type command (area). I exhibit you the way to do this with PHP in this post.</p>
<p>Case in point HTML Kind<br />
We shall make use of the subsequent HTML sort for illustration:<span id="more-390"></span></p>
</div>
<p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;form method=&#8221;post&#8221; action=&#8221;myPHP.php&#8221;&gt;<br />
&lt;br<br />
Name: &lt;input type=&#8221;text&#8221; name=&#8221;Name&#8221;&gt;&lt;br<br />
&lt;br<br />
Email: &lt;input type=&#8221;text&#8221; name=&#8221;Email&#8221;&gt;&lt;br<br />
&lt;br<br />
Message: &lt;textarea cols=&#8221;50&#8243; rows=&#8221;3&#8243; name=&#8221;Message&#8221;&gt;&lt;/textarea&gt;&lt;br &lt;br<br />
&lt;button type=&#8221;submit&#8221;&gt;Send&lt;/button&gt;<br />
&lt;/form&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<div>
<p>Inside the kind the approach is Publish plus the action attribute has the identify on the PHP file, myPHP.php. This PHP file as well as the HTML file for that form are inside exact directory at the server.</p>
<p>Feedback Technique<br />
Now the PHP file (script) includes a duplicate of your HTML Type website file code and it slots compact PHP code segments where error messages are expected inside the copy. For the HTML code over, a smaller PHP code segment might be slotted just above the tag for just a command inside copy. Every handle tag in the copy will have a specific PHP code segment above it, which is certainly accountable for its error concept.</p>
<p>With the commencing the consumer will contact the HTML kind in the browser. The fields will be empty. He then fills the sort and clicks the Send Button. The PHP system (myPHP.php) is called. The PHP program will validate the controls and when there are errors a little PHP code section above a control tag (duplicate) will send an error message again into the browser. If there may be no error, then the sole message sent back again can be which the form information and facts has long been efficiently obtained.</p>
<p>Now, if following suggestions may be sent with error message along with the person makes an error again, the PHP script will nevertheless be run for the reason that the copy of the internet form now on the browser however calls the identical PHP script from its action attribute. So, after the very first error may be dedicated through the consumer, the PHP script will retain calling alone, provided that the user keeps generating errors and clicking the Send button.</p>
<p>A simple PHP Program<br />
There are actually 4 primary code segments from the straightforward PHP program (script) I will supply you with. It operates with all the previously mentioned HTML file. The initial of these code segments will get the values from the controls sent in the internet type. The next of these segments will validate the controls and if there may be any error, it&#8217;ll set certain flag variables. If there exists any error the 3rd of these segments will deliver a comprehensive copy with the website form with slotted error messages again to a new web page in the browser. If there&#8217;s no error, the fourth of these segments will send a confirmation (saying kind information successfully obtained) to a new web page on the browser; in this instance the copy of the website type will not be sent again.</p>
<p>The first Primary Code Segment<br />
This is certainly the primary main code segment with the PHP script:</p>
</div>
<p>//obtain values from web form<br />
$ NameVal = $ _POST['Name'];<br />
$ EmailVal = $ _POST['Email'];<br />
$ MsgVal = $ _POST['Message'];</p>
<p>There&#8217;s a world-wide predefined array termed $ _POST in PHP. If you send the HTML form details with the post strategy then this array will have the values in the controls sent. To have the appeal of every management, you need the name of your handle. You assign the return worth to a variable with any identify you&#8217;d like. The 2nd Primary Code Segment This is the 2nd primary code segment:</p>
<p>//error flags<br />
$ errorOccurred;<br />
$ nameError;<br />
$ emailError;<br />
$ msgError;</p>
<p>//simple validation<br />
if ($ NameVal == &#8220;&#8221;)<br />
{<br />
$ errorOccurred = &#8220;true&#8221;;<br />
$ nameError = &#8220;true&#8221;;<br />
}<br />
if ($ EmailVal == &#8220;&#8221;)<br />
{<br />
$ errorOccurred = &#8220;true&#8221;;<br />
$ emailError = &#8220;true&#8221;;<br />
}<br />
if ($ MsgVal == &#8220;&#8221;)<br />
{<br />
$ errorOccurred = &#8220;true&#8221;;<br />
$ msgError = &#8220;true&#8221;;<br />
}</p>
<p>The initial 4 lines over are error flags (variables). If there is any error whatsoever, typed (triggered) from the user, then the £ errorOccurred variable could have the benefit, &#8220;true&#8221;. If there exists an error along with the user name, then $ nameError can have the price &#8220;true&#8221;. If there exists an error while using the electronic mail, then $ emailError could have the appeal &#8220;true&#8221;. If there&#8217;s an error with all the message subject then $ msgError could have the price, &#8220;true&#8221;. Following the above 4 lines, you&#8217;ve got four if-constructs.</p>
<p>These 4 constructs do some simple validations of your sent industry values. They basically check if a field worth was empty. You can make the validation more difficult than this if you need to, but I will not go into that in this article. If any area value is empty, then the generalized error variable, £ errorOccurred is granted the price, &#8220;true&#8221;; also the corresponding error variable is given the value, &#8220;true&#8221;. The values of these flag variables are going to be used to determine if suggestions error messages are to get sent again towards the browser.</p>
<p>The Third Principal Code Section It is the 3rd principal code section:</p>
<p>//display copy and error messages if error occurred<br />
if ($ errorOccurred == &#8220;true&#8221;)<br />
{<br />
echo &#8220;&lt;html&gt;\n&#8221;;<br />
echo &#8220;&lt;head&gt;\n&#8221;;<br />
echo &#8220;&lt;/head&gt;\n&#8221;;<br />
echo &#8220;&lt;body&gt;\n&#8221;;<br />
echo &#8221; &lt;form method=\&#8221;post\&#8221; action=\&#8221;myPHP.php\&#8221;&gt;\n&#8221;;<br />
if ($ nameError == &#8220;true&#8221;)<br />
{<br />
echo &#8220;&lt;span style=\&#8221;color:red\&#8221;&gt;The Name field cannot be empty!&lt;/span&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;br \n&#8221;;<br />
echo &#8220;Name: &lt;input type=\&#8221;text\&#8221; name=\&#8221;Name\&#8221; value=\&#8221;" . $ NameVal . &#8220;\&#8221;&gt;&lt;br \n&#8221;;<br />
if ($ emailError == &#8220;true&#8221;)<br />
{<br />
echo &#8220;&lt;span style=\&#8221;color:red\&#8221;&gt;The Email field cannot be empty!&lt;/span&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;br \n&#8221;;<br />
echo &#8220;Email: &lt;input type=\&#8221;text\&#8221; name=\&#8221;Email\&#8221; value=\&#8221;" . $ EmailVal . &#8220;\&#8221;&gt;&lt;br \n&#8221;;<br />
if ($ msgError == &#8220;true&#8221;)<br />
{<br />
echo &#8220;&lt;span style=\&#8221;color:red\&#8221;&gt;The Message field cannot be empty!&lt;/span&gt;&#8221;;<br />
}<br />
echo &#8220;&lt;br \n&#8221;;<br />
echo &#8220;Message: &lt;textarea cols=\&#8221;50\&#8221; rows=\&#8221;3\&#8221; name=\&#8221;Message\&#8221;&gt;&#8221; . $ MsgVal . &#8220;&lt;/textarea&gt;&lt;br &lt;br \n&#8221;;<br />
echo &#8220;&lt;button type=\&#8221;submit\&#8221;&gt;Send&lt;/button&gt;\n&#8221;;<br />
echo &#8220;&lt;/form&gt;\n&#8221;;<br />
echo &#8220;&lt;/body&gt;\n&#8221;;<br />
echo &#8220;&lt;/html&gt;\n&#8221;;<br />
}</p>
<div>
<p>All the code here is in a single major if-construct. The situation of your huge if-construct to begin with checks should the value with the generalized error variable (errorOccurred) is &#8220;true&#8221;. If it is actually legitimate then a duplicate on the online page has to be sent back again to the browser, with error massages slotted at suitable positions.</p>
<p>The PHP echo perform is made use of to deliver the lines in the copy from the internet web page.</p>
<p>Now, notice the little PHP code segments just over the tags of every management inside the duplicate. Each individual of them is surely an if-construct, which checks in the event the corresponding flag variable is &#8220;true&#8221;. If it really is true, then the block with the if-construct sends the error message.</p>
<p>Notice that whilst sending a copy of your regulate tags, the value from the manage, and that is what the person typed, is additionally sent; using this type of the person may not have to retype the area value.</p>
<p>So the third main code segment (block of substantial if-construct) operates only if there was not less than one particular error. If there was no error, then the third main code segment will not run; it is actually the fourth primary code section that can operate.</p>
<p>The Fourth Major Code Segment<br />
That is the fourth primary code section:</p>
</div>
<p>//if no error occurred, send feedback that web info has been received<br />
if ($ errorOccurred != &#8220;true&#8221;)<br />
{<br />
echo &#8220;&lt;html&gt;\n&#8221;;<br />
echo &#8220;&lt;head&gt;\n&#8221;;<br />
echo &#8220;&lt;/head&gt;\n&#8221;;<br />
echo &#8220;&lt;body&gt;\n&#8221;;<br />
echo &#8220;&lt;h1 style=\&#8221;color:darkblue\&#8221;&gt;Thank you.&lt;/h1&gt;\n&#8221;;<br />
echo &#8220;&lt;h2 style=\&#8221;color:darkblue\&#8221;&gt;The Information has been received.&lt;/h2&gt;\n&#8221;;<br />
echo &#8220;&lt;/body&gt;\n&#8221;;<br />
echo &#8220;&lt;/html&gt;\n&#8221;;<br />
}</p>
<div>
<p>This section is one more significant if-construct. It checks if there was any (a minimum of 1) error utilizing the generalized error variable, errorOccurred. If there was no error, then it sends a confirmation message to a new page on the browser. Using this script you don&#8217;t need to have any particular assertion to deliver the tags to some new browser web page. In the event the script was known as from the browser, then just about every echo instruction will deliver its argument to the very same net page on the browser.</p>
<p>Remarks<br />
In practice, for that net page, chances are you&#8217;ll want a heading on the top on the sort to point that an error has occurred, in a single with the controls, and after that the person can scroll down to see the actual management and its error. You could attain (code) that making use of the generalized error variable, errorOccurred. In the website web page copy while in the script an H3 factor along with the generalized error concept might be sent just under the get started tag on the sort.</p>
<p>Following the PHP script has systematically received the values with the sort controls, you&#8217;ll be able to do whichever you desire to accomplish along with the values. You can deliver them to a database; you are able to deliver them to a printer otherwise you can send them to an e mail box. Check with my article sequence regarding how to deliver email with PHP, titled, Sending Email with PHP.</p>
<p>Conclusion<br />
To possess similar page feedback for a internet sort, the PHP script known as will need to have a copy with the website type web page. If you can find an error concept, the duplicate is sent back again together with the error concept slotted at a related position of your duplicate. The duplicate is in echo statements and not in isolation. The internet (HTML) sort is called after; soon after that if the person retains making mistakes, it&#8217;s the PHP script that may be termed (calling alone) around and above once again.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/php-on-page-validation-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Variables of PHP Scopes</title>
		<link>http://www.phpide.com/php-tutorials/variables-of-php-scopes/</link>
		<comments>http://www.phpide.com/php-tutorials/variables-of-php-scopes/#comments</comments>
		<pubDate>Sun, 28 Aug 2011 13:03:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[php tutorials for beginners]]></category>
		<category><![CDATA[PHP Variables]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=391</guid>
		<description><![CDATA[Whenever you declare a variable outside a perform, it might not be found within the function. If you declare a variable within a perform, it may not be noticed outdoors the perform. That aspect is referred to as variable scope. I reveal the fundamentals of PHP variable scope during this post. You require standard know-how [...]]]></description>
			<content:encoded><![CDATA[<div>Whenever you declare a variable outside a perform, it might not be found within the function. If you declare a variable within a perform, it may not be noticed outdoors the perform. That aspect is referred to as variable scope. I reveal the fundamentals of PHP variable scope during this post.</p>
<p>You require standard know-how in PHP so as to understand this sequence. In the event you don&#8217;t have that prerequisite understanding, then examine the series I wrote within this website titled,</p>
<p>Passing Arguments<br />
Look at the adhering to code:<em><br />
</em></div>
<p>&lt;?php</p>
<p>$ a = 4;</p>
<p>function sendValue($ x)<br />
{<br />
echo $ x;<br />
}</p>
<p>sendValue($ a);</p>
<p>?&gt;</p>
<p>Inside the over code, the variable, $ a is declared outside the operate. The definition on the functionality, basically sends the worth of its argument to the browser. If the purpose is termed, the variable, $ a is sent as argument. This worth is echoed. Now be aware two factors: This variable is declared exterior the perform. It is passed on the operate as an argument. Within the perform definition, the variable echoed is the parameter variable in the perform and never the variable declared outdoors the perform. Since the worth with the variable, declared outside the operate is passed as argument, with the definition of your perform, this value will become the value on the parameter variable.</p>
<p>Whenever a variable is declared exterior a function and passed as argument towards the purpose, the definition of the purpose sees the variable. The over code will work. Now, consider the adhering to code and note that it does not do the job:</p>
<p>&lt;?php</p>
<p>$ a = 4;</p>
<p>function sendValue()<br />
{<br />
echo $ a;<br />
}</p>
<p>sendValue();</p>
<p>?&gt;</p>
<div>Right here<em>, the variable </em>remains to be<em> declared </em>outside<em> the </em>purpose<em>. The </em>operate<em> </em>does not<em> have any parameter. </em>When the<em> </em>operate<em> </em>is termed<em>, the variable </em>is not<em> sent </em>as an<em> argument. </em>On the other hand<em>, </em>with the<em> </em>functionality<em> definition, the variable declared </em>outside<em>, </em>instead of<em> the parameter variable, is </em>anticipated<em> </em>to become<em> echoed. </em>In a few<em> </em>laptop or computer<em> languages, the </em>previously mentioned<em> code will </em>perform<em>. In PHP, </em>it doesn&#8217;t<em> </em>perform<em> </em>mainly because<em> a PHP </em>functionality<em> </em>are not able to<em> see a variable declared </em>exterior<em> its definition; </em>that is<em> just the rule of PHP.</p>
<p></em>World-wide<em> and </em>Regional<em> Variables<br />
In PHP, any variable declared </em>outside<em> a </em>operate<em> as $ a </em>over<em>, </em>is often a<em> </em>international<em> variable. In PHP any variable declared </em>inside<em> a </em>function<em> (see </em>below<em>), </em>is actually a<em> </em>nearby<em> variable. </em>With the<em> </em>adhering to<em> code, the $ a declared </em>outside<em> the </em>operate<em> </em>along with the<em> $ a declared </em>within<em> the </em>function<em> are </em>entirely<em> two </em>various<em> </em>points<em>. </em>Browse<em> and </em>try<em> the </em>adhering to<em> code:</em></div>
<p>&lt;?php</p>
<p>$ a = 4;</p>
<p>function sendValue()<br />
{<br />
$ a;<br />
echo $ a;<br />
}</p>
<p>echo &#8220;Value of variable outside&lt;br &#8220;;<br />
echo $ a; echo &#8220;&lt;br &#8220;;</p>
<p>echo &#8220;Value of variable inside&lt;br &#8220;;<br />
sendValue();</p>
<p>?&gt;</p>
<div>When you can see on the result, the 2 variables, nevertheless possessing the identical name, but by the reality that one particular is outside the operate along with the other is inside of, would hold diverse values. The 1 inside of the function within this situation, did not even acquire a value.</p>
<p>The reserved word, world wide<br />
If you want the variable declared outside a function to maintain the same worth as being the a person within the perform, you&#8217;ve got to re-declare the one particular inside of the functionality, preceding it while using the reserved phrase, worldwide, as in the following code:<em><br />
</em></div>
<p>&lt;?php</p>
<p>$ a = 4;</p>
<p>function sendValue()<br />
{<br />
global $ a;<br />
echo $ a;<br />
}</p>
<p>echo $ a; echo &#8220;&lt;br &#8220;;<br />
sendValue();</p>
<p>?&gt;</p>
<p>Within the outcome, the two values displayed would be the similar. This illustrates the usage of the reserved term, global.</p>
<p>Superglobals<br />
PHP has variables called super worldwide variables, or simply, Superglobals. They are variables that could be viewed outside and inside of capabilities without having the usage of the reserved word, world-wide. The programmer isn&#8217;t allowed to declare this sort of variables. You will find only many of them accessible and they are predefined. Examples of superglobals will be the $ _POST and $ _GET variables. They&#8217;re really arrays, not variables.</p>
<p>Note: Any time a world wide variable is passed as argument to a function, the operate definition will see the appeal in the variable; on the other hand, this doesn&#8217;t make the global variable, neighborhood or superglobal.</p>
<p>You will find other items to find out about variable scope, but to the goal of the tutorial, we shall stop right here. We continue with anything else within the next a part of the series.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/variables-of-php-scopes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Errors and Mistakes Tutorial</title>
		<link>http://www.phpide.com/php-tutorials/php-errors-and-mistakes-tutorial/</link>
		<comments>http://www.phpide.com/php-tutorials/php-errors-and-mistakes-tutorial/#comments</comments>
		<pubDate>Sat, 27 Aug 2011 14:28:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[php errors]]></category>
		<category><![CDATA[php tutorial for beginners]]></category>
		<category><![CDATA[php tutorials]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=393</guid>
		<description><![CDATA[Programming Problems There are actually a few different types of programming mistakes. Put simply, you&#8217;ll find 3 sorts of mistakes which will manifest in a very program. You&#8217;ve Syntax Problems, Logic Mistakes and Runtime Errors. Syntax Errors This is actually the wrong utilization of syntax. These mistakes are incorrect statements. When you sort a declaration, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Programming Problems</strong><br />
There are actually a few different types of programming mistakes. Put simply, you&#8217;ll find 3 sorts of mistakes which will manifest in a very program. You&#8217;ve Syntax Problems, Logic Mistakes and Runtime Errors.</p>
<p><strong>Syntax Errors</strong><br />
This is actually the wrong utilization of syntax. These mistakes are incorrect statements. When you sort a declaration, which happens to be mistaken, that is a syntax error. This sort of a declaration cannot be executed. One example is, inside a statement you&#8217;ll be able to kind a variable with out the $ signal. Under this problem, your application doesn&#8217;t get the job done. Determined by the way you configure your PHP installation, this kind of an error may well be indicated by PHP towards the output product just ahead of the system should be to be executed, whenever you give a command to run the software. By using a syntax error, the application just isn&#8217;t executed. Ahead of PHP code is executed, you can find some minimum amount compilation that requires location. Syntax problems could well be spotted because of the PHP compiler and reported, and execution (interpretation) in the system will not acquire spot.</p>
<p><strong>Logic Problems</strong><br />
In this instance, PHP interpreter understands your plan quite properly and it executes the system. Even so, the software will never do that which you wished it to try and do. It&#8217;s going to do a little something slightly unique or absolutely distinct. The fault is yours. For instance, a loop that is necessary to do 10 iterations may do five iterations, since you coded it mistakenly to carry out 5 iterations. An additional example is usually that a loop could iterate infinitely, since the ailment you gave to the loop is wrong. Logic Problems occur when the system is staying executed (interpreted). The sole solution to solve this challenge is always to check your plan pretty very well just before you hand it on the customer (who asked for it).</p>
<p><strong>Runtime Problems</strong><br />
Runtime problems manifest when the plan is getting executed consequently in the proven fact that you did not get sure factor into consideration when coding. For instance, let us say your code should be to divide eight by some denominator that the consumer inputs. If your person inputs two, the division will function, supplying you with 4 as response. In the event the person inputs zero, the division is not going to function, since 8/0 is undefined. Any time a runtime error occurs your method generally crashes (and prevent). To solve runtime problems, you will need to compose code that could reduce the execution with the certain code segment from taking place. During this division example, you must publish code that should avert division by zero from occurring, and possibly informing the user with the error he created by inputting zero being a denominator.</p>
<p><strong>Avoiding Runtime Problems</strong><br />
Runtime mistakes are prevented applying what is identified as try-catch blocks. We shall make use of the case in point of dividing 8 by a denominator to illustrate this. Look at the following code:</p>
<p>&lt;?php</p>
<p>$ input = 2;</p>
<p>try<br />
{<br />
if ($ input == 0)<br />
throw new Exception(&#8216;Division by zero is not allowed.&#8217;);<br />
$ var = 8 / $ input;<br />
echo $ var;<br />
}<br />
catch (Exception $ e)<br />
{<br />
echo &#8220;Error: &#8220;, $ e-&gt;getMessage();<br />
}</p>
<p>?&gt;</p>
<p>Try out the previously mentioned code. It is best to have 4 as the respond to, displayed. Now improve the value of the $ input variable at the beginning on the code to 0. You should have the text, &#8220;Error: Division by zero just isn&#8217;t permitted.&#8221; exhibited.</p>
<p>The code divides eight because of the value in the $ input variable. Once the price from the $ input variable is not zero, all is high-quality. Once the worth is zero, that may be an error, and therefore the program ought to not crash. Code has to be created to forestall the application from crashing.</p>
<p>You will find 4 important things you&#8217;ll want to notice in regards to the code above. There&#8217;s the try-block; there&#8217;s the catch-block; there&#8217;s an object established from the course named Exception; and there is certainly a declaration referred to as the toss assertion round the starting of the attempt block.</p>
<p>The try-block commences together with the reserved phrase, try out, then you definitely hold the pair of curly braces. The statements for that look at block are with the curly braces. The catch-block starts together with the reserved phrase, catch. It&#8217;s got parentheses by using a parameter. The parameter is really a variable, preceded by the variable variety (we have now not seen this variable style in advance of). The catch-block provides a pair of curly braces. The statements with the catch block go in to the curly braces.</p>
<p>The extremely first declaration with the try-block is definitely an if-statement blended with what is named the throw declaration? The thought is the fact that you check in the event the $ input variable is zero. If it truly is zero, then the throw declaration is executed to stop crash. If the throw statement is executed, we say an exception is thrown. When an exception is thrown, the statements below the throw declaration within the check out block are not executed; while the statements within the catch-block must be executed; that is certainly, when an error takes place, the statements down below the throw statement inside the try-block usually are not executed, even though the catch-block has to be executed to deal with the situation. If no error occurs (in this case, input is just not zero), then an exception will not be thrown. If an exception is not really thrown, the statements below the throw statements in the try-block are executed, plus the catch-block just isn&#8217;t executed.</p>
<p>The try-block has the typical statements to be executed to solve task required with the method. These statements are executed on ailment that no error has occurred. The catch block has the statements to get executed if an error happens. Often what the catch block does is the fact that it simply informs the person that an error has occurred by using a quick description on the error. If the error is detected in the look at block as well as catch block is executed as with the over code, then the method will not crash. I repeat, commonly, the catch-block would not do considerably over exhibit a short error message to your person. Prevention of crash is on account of the very fact which the normal statements with the check out block are usually not executed plus the catch-block is executed.</p>
<p>Introduction to the Exception Course<br />
You can find a class termed the Exception class. This class has a great amount of members and solutions. For this simple tutorial we shall chat about only one of its members. The member retains the error information you need to give on the user. You, the programmer, would be the one who decides to the error information. You feed while in the error message after you create an object on the class. You build an object at the same time that you are throwing the exception. In the above code, we&#8217;ve,</p>
<p>throw new Exception(&#8216;Division by zero isn&#8217;t permitted.&#8217;)</p>
<p>Here, the reserved phrase, toss, is usually to throw the exception. The exception is an object, which could possess the error concept and other important things. With this tutorial, we take into consideration only the error message. To produce an exception object, we commence while using the operator, new. This can be adopted, through the identify of the course, Exception; then parentheses. From the parentheses, you style the error message in estimates. The Exception course features a constructor approach that assigns this error concept as worth to 1 of its members (a single of its variables). This exception object is thrown to get caught be considered a catch-block. So the if-statement detects the error, throws an exception object, which is aware of the error as well as the catch-block catches the exception object. The catch-block employs information while in the exception object to complete the error managing.</p>
<p>The catch-block<br />
The catch is like a functionality. It has parentheses, which has a parameter. The parameter will be the variable for an exception object. You decide on what ever title you wish for the variable, and precede it with the $ indicator. You precede the variable with the phrase, Exception. This implies the kind of variable is surely an exception. The throw-statement is like a get in touch with into the catch-block.</p>
<p>In the above code, we now have the echo declaration. The echo construct requires a comma-separated checklist of arguments. In this instance, the first argument may be the string &#8220;Error: &#8220;. This string are going to be displayed initial at the browser. This string suggests to the consumer that there&#8217;s an error. The description with the error follows through the next argument. This future argument into the echo assemble is really a return appeal of the system on the exception object. What now we have accurately is:</p>
<p>$ e-&gt;getMessage()</p>
<p>$ e is the catch parameter variable, which is the object caught that was thrown. getMessage() is the method to return the error message that we typed when creating the object. This is the only exception class method we consider in this tutorial.</p>
<p>Some Remarks<br />
There is certainly an aged way of managing runtime errors in PHP; I will not examine that. There are also predefined exceptions; I will also not focus on that for this basic tutorial. What I have given you on this tutorial is plenty of to get you heading in PHP programming.</p>
<p>The NULL Price<br />
This area is not truly handling problems, but is occasionally connected with problems. The reserved phrase, NULL, whose letters can be in any situation (higher or lower) could be assigned to a variable, like in,</p>
<p>$ someVar = null;</p>
<p>When a variable is declared devoid of any appeal assigned to it, the variable is regarded as NULL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/php-errors-and-mistakes-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP extensions utilizing Delphi</title>
		<link>http://www.phpide.com/php-news/php-extensions-utilizing-delphi/</link>
		<comments>http://www.phpide.com/php-news/php-extensions-utilizing-delphi/#comments</comments>
		<pubDate>Fri, 26 Aug 2011 19:09:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP News]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[php extensions]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=394</guid>
		<description><![CDATA[PHP4Delphi is really a 1st Visual Progress Framework for building customized PHP Extensions using Delphi. PHP4Delphi helps you embed the PHP interpreter into your Delphi application and execute the PHP scripts within the Delphi application directly devoid of a WebServer. It could integrate PHP with any application. Applying PHP4Delphi it is possible to make native [...]]]></description>
			<content:encoded><![CDATA[<p>PHP4Delphi is really a 1st Visual Progress Framework for building customized PHP Extensions using Delphi. PHP4Delphi helps you embed the PHP interpreter into your Delphi application and execute the PHP scripts within the Delphi application directly devoid of a WebServer. It could integrate PHP with any application. Applying PHP4Delphi it is possible to make native PHP extension inside of a couple of minutes. PHP4Delphi also allows executing the PHP scripts in the Delphi software instantly from file or memory. You are able to browse and write world PHP variables and set the final result worth. PHP4Delphi permits you to embed the PHP interpreter into your Delphi application and that means you can extend and customize the application with no getting to recompile it.<span id="more-394"></span></p>
<p>Why do we want a PHP extension? There are several motives why extensions are desired. One particular of them, as already mentioned , would be to add new performance to PHP. However, PHP extensions applying Delphi Enhancement India are also applied to enhance the efficiency and pace of our packages. One more probable motive to use extensions is to reuse generally utilized code. As an alternative to going precisely the same outdated capabilities from undertaking to undertaking, you can put all of them in one extension and allow all your assignments to use that extension. A typical PHP4Delphi is often arranged to the adhering to subprojects. PHP scripting (making use of PHP in Delphi programs) PHP4Delphi permits to execute the PHP scripts within the Delphi application instantly without having a WebServer. This application is appropriate with PHP 4 and PHP five. The PHP API and ZEND API transformed from C to Delphi. The phpLibrary part which permits to include new build-in PHP capabilities to psvPHP element. PHP4Delphi permits you to embed the PHP interpreter into your The PHP API and ZEND API transformed from C to Delphi. Delphi application and that means you can lengthen and personalize the software without owning to recompile it. New to make PHP extensions using Delphi. A PHP extension, in the most simple of terms, is usually a set of guidelines (i.e. code) that is definitely meant to add performance to PHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-news/php-extensions-utilizing-delphi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using PHP and HTML to create vibrant, dynamic web sites!</title>
		<link>http://www.phpide.com/php-tutorials/using-php-and-html-to-create-vibrant-dynamic-web-sites/</link>
		<comments>http://www.phpide.com/php-tutorials/using-php-and-html-to-create-vibrant-dynamic-web-sites/#comments</comments>
		<pubDate>Wed, 24 Aug 2011 07:02:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[designing]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[websites]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=395</guid>
		<description><![CDATA[If you ever approach to create a online internet page with the close to foreseeable future, or potentially have a very contemporary internet page upward previously, you could be thinking about the most beneficial tactics to touch up up your Html web page expertise. Figuring out the way to code totally in HTML is mostly [...]]]></description>
			<content:encoded><![CDATA[<div>If  you ever<em> </em>approach<em> to </em>create<em> a </em>online<em> </em>internet  page<em> </em>with  the<em> </em>close  to<em> </em>foreseeable  future<em>, or </em>potentially<em> </em>have  a very<em> </em>contemporary<em> </em>internet  page<em> upward </em>previously<em>, </em>you  could<em> be </em>thinking  about<em> </em>the  most beneficial<em> </em>tactics<em> to touch up up your Html </em>web  page<em> </em>expertise<em>. </em>Figuring  out<em> </em>the  way to<em> code </em>totally<em> in HTML </em>is  mostly a<em> </em>terrific<em> </em>expertise<em> </em>to  possess<em>. </em>The  net<em> </em>incorporates  a<em> </em>ton<em> of other </em>approaches<em> to rule, </em>various<em> coming from HTML </em>to  be able to<em> PHP &amp; additional, more advanced languages, but  realizing basic Html code has always been an incredible foundational ability </em>to  get<em>. Although </em>it&#8217;s  possible you&#8217;ll<em> do many of these website be employed in a WYSIWYG  editor, you still require a solid foundation on the essentials of Programming to  be a top-notch website design company. Even </em>the  ideal<em> internet editing plans make mistakes that </em>can<em> require you to will end up in and make a few fixes by hand. If you&#8217;re serious  about </em>studying<em> Html code you&#8217;ll find several </em>incredible<em> training &amp; lessons available that can help you learn this specific  skill.<span id="more-395"></span></p>
<p></em><em>Right now there can also be use of colors inside </em>world-wide-web<em> </em>web  page<em> developing which helps within separation via those of the average  designs that happen to be make by simply viewers. This is the main job and role  of the website design company to do various kinds of things inside the website  even though filling different colors within the website creating. Choosing of  the appropriate shades are very important when it comes to readability with the </em>web  site<em> making certain the colors which can be being chosen are shareable  by other persons.</em></p>
<p><em> </em><em>Those who are in to digital photography are almost  certainly experts in terms of PhotoShop. This software is crucial in editing  standard photos to get perfect and artistic photos using different varieties of  effects such as the appropriate coloration saturation. Even so, not all people  have the knowledge with regards to PhotoShop and </em>a  whole lot of<em> people wish to know </em>ways  to<em> change a simple photograph into a creative piece. </em>In  an effort to<em> learn the tricks of PhotoShop, you just have to use  specific books and PhotoShop courses. Most people rely in PhotoShop training  especially in </em>getting  to know<em> new things since with PhotoShop courses, they do not will need  to go through diverse books and also seek advice from their particular  friends.</em></p>
<p><em> </em><em>It was a quick overview of </em>the  world wide web<em> advancement process. To find great means on the  internet Yahoo and google &#8220;Web Development Tutorials&#8221;, &#8220;dreamweaver tutorials&#8221;,  &#8220;Web Design and style Tutorials&#8221;, and so on. </em>When  you<em> are interested in becoming an online </em>blog<em> programmer studying languages like PHP, Or net, JAVASCRIPT and so on. An  excellent opportunity checking out courses at your neighborhood college or  searching Yahoo for &#8220;beginners instructions to programming&#8221;.A quick recap * </em>the  world wide web<em> advancement process works like this. You will build  your website in dreamweaver and save the particular </em>web  page<em> you create while index.html &#8211; Then you definitely create  sub-pages including contactus.html, aboutus.html code, services.</em>world-wide-web<em> coding, and then you url to them from your home </em>web  page<em>. Then you will proceed to upload your list.html document and all  additional files employing filezilla to your internet hosting accounts actual  directory.</em></p>
<p><em> </em><em>Next step within the development process is that you must  obtain a domain name (or website domain url) &#8211; you can accomplish this by  browsing google for domain names. A url of your website example will be  &#8220;yourwebsite.com&#8221;. You will also need to find a </em>world  wide web<em> </em>webpage<em> number to manage your current files. An internet </em>blog<em> host merely stores your </em>web  site<em> </em>page<em> over a computer inside a datacenter that can be accessed by the earth wide  net.</em></p>
<p><em> </em><em>GIF files employ index colour. Index shade consists of 216 frequent  colors available on all laptop or computer monitors as well as within just about  all </em>World  wide web<em> browsers. These kind of common colours reside in an internet  palette. </em>The  net<em> palette of colors is available in Macromedia Fireworks along with  Adobe Photoshop for them to be used inside design of </em>World-wide-web<em> screens with no variance regarding color if the pages are on the Internet. Also, </em>the  world wide web<em> palette is the regular color palette throughout  Macromedia Dreamweaver and Macromedia Expensive. This allows us all to achieve  constant color over </em>Online<em> software and Internet browsers.</em></p>
</div>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="src" value="http://www.youtube.com/v/4oSCuEtxRK8?fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="355" src="http://www.youtube.com/v/4oSCuEtxRK8?fs=1" allowfullscreen="true"></embed></object></p>
<p><strong>Related:</strong> <a href="http://www.phpide.com/category/php-tutorials/">PHP Tutorials for Beginners</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/using-php-and-html-to-create-vibrant-dynamic-web-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why you might be a crap PHP programmer!</title>
		<link>http://www.phpide.com/php-news/why-you-might-be-a-crap-php-programmer/</link>
		<comments>http://www.phpide.com/php-news/why-you-might-be-a-crap-php-programmer/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 19:09:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP News]]></category>
		<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[php programming]]></category>
		<category><![CDATA[Programmer]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=396</guid>
		<description><![CDATA[All of us have our poor routines. Within this write-up, we&#8217;ll go more than a checklist of poor practices which are really worth examining, reevaluating, and correcting instantly. Who the Hell Do You&#8217;re thinking that You&#8217;re? Each and every time I open up a undertaking that is not mine, it is accompanied by a tinge [...]]]></description>
			<content:encoded><![CDATA[<div>All  of us<em> have our </em>poor<em> </em>routines<em>. </em>Within  this<em> </em>write-up<em>,  we&#8217;ll go </em>more  than<em> a </em>checklist<em> of </em>poor<em> practices </em>which  are<em> </em>really  worth<em> examining, reevaluating, and correcting </em>instantly<em>.</p>
<p>Who  the Hell Do </em>You&#8217;re  thinking that<em> </em>You&#8217;re<em>?</p>
<p></em>Each  and every<em> time I </em>open  up<em> a </em>undertaking<em> that </em>is  not<em> mine, </em>it  is<em> accompanied by a tinge of </em>worry<em> that </em>I  am<em> </em>strolling<em> into </em>some  sort of<em> Temple of Doom </em>situation<em>, </em>stuffed<em> with </em>lure<em> </em>doorways<em>, </em>key<em> codes, and that </em>1<em> line of code that, </em>on<em> alteration, brings down </em>the  whole<em> app (and </em>probably<em> sends a </em>large<em> boulder hurtling </em>towards<em> me down a </em>slim<em> hallway).<span id="more-396"></span></p>
<p>When we&#8217;re </em>incorrect<em>,  and </em>every  thing<em> is </em>good<em> </em>aside  from<em> some </em>small<em> </em>variations<em> in &#8220;how </em>I&#8217;d<em> have </em>carried  out<em> it,&#8221; we breathe a sigh of relief, roll up our sleeves, and dive </em>in  to the<em> </em>undertaking<em>.</p>
<p>But  when we&#8217;re right… </em>Nicely<em>, </em>that  is<em> </em>an  entire<em> </em>various<em> </em>tale<em>.</p>
<p>Our </em>initial<em> </em>believed<em> </em>on<em> </em>viewing<em> this unholy mess </em>is  generally<em> </em>alongside<em> the lines of, &#8220;Who the hell does this </em>man<em> </em>believe<em> </em>he&#8217;s<em>?&#8221;  And rightfully so; </em>what  sort of<em> programmer would willingly </em>produce<em> </em>this  kind of<em> an unholy mess </em>from<em> a </em>undertaking<em>?<br />
</em>The  solution<em> </em>May<em> </em>Shock<em> You</p>
<p></em>Terrible<em> code </em>will  be the<em> accumulation of </em>numerous<em> </em>little<em> shortcuts or concessions.</p>
<p>Your </em>initial<em> instinct </em>may  be<em> to </em>presume<em> </em>the<em> </em>man<em> who </em>constructed<em> the </em>undertaking<em> </em>is  really a<em> </em>newbie<em>,  or </em>perhaps<em> </em>he  is<em> just an idiot. But </em>that  is<em> not </em>usually<em> </em>the  situation<em>.</p>
<p>My </em>concept<em> </em>is  the fact that<em> </em>terrible<em> code </em>will  be the<em> accumulation of </em>numerous<em> </em>little<em> shortcuts or concessions &#8211; </em>equally  as<em> </em>frequently<em> as </em>it  is the<em> </em>item<em> of inexperience or stupidity. This </em>tends  to make<em> the Temple of Doom app </em>a  lot<em> scarier, </em>simply  because<em> whoever </em>constructed<em> </em>it  could be<em> </em>equally  as<em> </em>intelligent<em>,  savvy, and well-read </em>when  you<em> are. They just </em>received<em> lazy or </em>place<em> </em>issues<em> </em>collectively<em> </em>inside  a<em> rush, and </em>every<em> of </em>these<em> </em>small<em> shortcuts </em>additional<em> up </em>in  to the<em> winding nightmare that just fell </em>inside  your<em> lap.</p>
<p>Even scarier, </em>this  might<em> </em>imply<em> that </em>sooner  or later<em>, </em>somebody<em> inherited your code and </em>instantly<em> burst into tears.<br />
</em>You  are<em> </em>Much  better<em> Than That, </em>Infant<em>!</p>
<p>It </em>by  no means<em> hurts to reexamine your </em>present<em> practices </em>and  ensure<em> </em>you  are not<em> taking any shortcuts </em>that  can<em> be contributing to </em>somebody<em> else&#8217;s </em>misplaced<em> </em>rest<em>.</p>
<p></em>Let  us<em> </em>consider<em> </em>a  couple of<em> minutes and go </em>more  than<em> some </em>typical<em> shortcuts, concessions, </em>along  with other<em> </em>poor<em> practices </em>to  make sure<em> that our </em>tasks<em> </em>are  not<em> striking </em>worry<em> </em>in  to the<em> hearts </em>with  the<em> villagers.<br />
</em>You  do not<em> </em>Strategy<em> </em>Prior  to<em> </em>You  begin<em> Coding</p>
<p></em>Prior  to<em> you </em>create<em> </em>just  one<em> line of code, </em>you  need to<em> </em>possess  a<em> </em>strong<em> </em>strategy<em> of </em>assault<em>.</p>
<p></em>Prior  to<em> you </em>create<em> </em>just  one<em> line of code, </em>you  need to<em> </em>possess  a<em> </em>strong<em> </em>strategy<em> of </em>assault<em>.  This </em>assists<em> </em>maintain<em> you </em>on  the right track<em> and avoids wandering code </em>which  will<em> confuse you </em>later  on<em>, </em>to  not<em> </em>point  out<em> </em>another<em> </em>bad<em> soul.</p>
<p></em>1<em> </em>method<em> </em>which  has<em> saved me time &#8211; </em>each<em> in </em>advancement<em> and in commenting &#8211; </em>would  be to<em> </em>create<em> an outline in </em>feedback<em> </em>initial<em>:<br />
</em>see<em> plaincopy to clipboardprint?<br />
&lt;?php</p>
<p>// Include necessary  data</p>
<p>// Initialize the database connection</p>
<p>// Include the common  header markup</p>
<p>// Determine the page variables from the POST  data</p>
<p>// Load the proper database info using the page vairiables</p>
<p>//  Loop through the loaded rows</p>
<p>// Format the images for display</p>
<p>//  Create a permalink</p>
<p>// Format the entry for display</p>
<p>// Add the  formatted entry to the entry array</p>
<p>// Collapse the entry array into  page-ready markup</p>
<p>// Output the entries</p>
<p>// Include the common  footer markup</p>
<p>As you can see, without writing a single line of code, I  already know almost exactly what the file will look like. Best of all, you can  plan out an entire application this way, and if you get to a point where one  feature requires a functionality tweak to another, all you have to do is change  the comment.</p>
<p>It requires a shift in the way you approach development, but  it will make your project organization skills go through the roof.</p>
<p>NOTE:  Some of these comments aren&#8217;t necessary; some of them will change; others will  need to be added &#8211; that&#8217;s expected. This is kind of like writing an outline for  a paper or writing a grocery list: it just keeps you on the right track when you  go to finish the job.<br />
You Don&#8217;t Comment Anything</p>
<p>Yet the single worst  problem with most code that I encounter is that it&#8217;s poorly commented, or not  commented at all.</p>
<p>It makes me sad that I have to write this down. When  something is as easy as commenting, it shouldn&#8217;t be something we have to remind  each other to do.</p>
<p>Yet the single worst problem with most code that I  encounter is that it&#8217;s poorly commented, or not commented at all. This not only  adds a good chunk of time to my initial familiarization with the project, but it  pretty much guarantees that a fix made using an unconventional method out of  necessity will confuse me. Then, if I end up doing any refactoring, I&#8217;ll  inadvertently break the app because I haven&#8217;t encountered the extenuating  circumstances that required the fix.</p>
<p>This process can take anywhere from  10 minutes to 6 hours. (And you&#8217;ve done this to me, I know where you live. I&#8217;m  coming for you.)</p>
<p>So say this out loud:</p>
<p>I, [state your name],  hereby swear to make comments in any situation where the purpose of the code  I&#8217;ve written isn&#8217;t immediately apparent.</p>
<p>&#8220;Immediately apparent&#8221; refers to  code that can&#8217;t be self-documenting (because it wouldn&#8217;t be reasonable to do so)  and/or doesn&#8217;t complete a dead-simple task. Think about it this way: if you had  to stop and think about your solution for more than a few seconds, it probably  merits a quick line of explanation.</p>
<p>To illustrate my point, I&#8217;m going to  use an example from an article I wrote recently for beginners. Consider the  following:<br />
view plaincopy to clipboardprint?<br />
$ pieces = explode(&#8216;.&#8217;, $  image_name);<br />
$ extension = array_pop($ pieces);</p>
<p>What does that do? Did  you have to stop and think about it? Do you still not know for sure what&#8217;s  stored in $ extension?</p>
<p>Look at that snippet again, but with one quick  comment:<br />
view plaincopy to clipboardprint?</p>
<p>// Get the extension off  the image filename<br />
$ pieces = explode(&#8216;.&#8217;, $ image_name);<br />
$ extension =  array_pop($ pieces);</p>
<p>Five seconds at a time will add up in a big  way.</p>
<p>Now glancing at this code doesn&#8217;t require any additional brain  power: you see the comment, see the code, and never have to question its  intent.</p>
<p>It might only save you five seconds of contemplation, but if  you&#8217;ve got a complex app, five seconds at a time will add up in a big  way.</p>
<p>So stop making excuses. Write the damn comment.<br />
You Sacrifice  Clarity for Brevity</p>
<p>Good examples of sacrificing clarity for brevity  include unclear variable names and dropping the curly braces.</p>
<p>It&#8217;s a  universal temptation to get something done in as few characters as possible, but  that temptation is kind of like the temptation to only have one pair of  underwear: sure, the laundry gets done quickly, but the problems that arise from  your choice hugely outweigh the benefits.</p>
<p>Good examples of sacrificing  clarity for brevity include short, unclear variable names (such as $ a &#8211; what  does $ a store?) and dropping the curly braces.</p>
<p>Dropping curly braces  from control structures is a particular pet peeve of mine. If you don&#8217;t like  curly braces, switch to Python. In PHP, it&#8217;s just too easy to lose the meaning  without them.</p>
<p>For example, look at this set of nested if-else statements  without curly braces:<br />
view plaincopy to clipboardprint?<br />
&lt;?php</p>
<p>$  foo = 8;</p>
<p>if( $ foo&lt;10 )<br />
if( $ foo&gt;5 )<br />
echo &#8220;Greater than </em>five<em>!&#8221;;<br />
else<br />
echo  &#8220;Less than </em>five<em>!&#8221;;<br />
else<br />
echo  &#8220;Greater than </em>ten<em>!&#8221;;<br />
echo  &#8221;<br />
</em>An  additional<em> </em>be  aware<em>.&#8221;;</p>
<p></em>In  a<em> glance, it </em>seems  like<em> the </em>final<em> line </em>ought  to<em> only </em>hearth<em> </em>when  the<em> </em>worth<em> of $ foo is </em>higher<em> than </em>ten<em>.  But </em>what  is<em> </em>really<em> </em>occurring<em> </em>is  really a<em> </em>situation<em> of </em>incorrect<em> indenting; the </em>final<em> echo </em>declaration<em> will </em>hearth<em> </em>regardless  of what<em><br />
$ foo </em>shops<em>.</p>
<p></em>Are  you able to<em> figure it out </em>in  the event you<em> </em>take  a look at<em> it </em>to  get a<em> </em>couple  of<em> seconds and </em>understand  that<em> if-else statements </em>with  out<em> curly braces only </em>impact<em> the </em>instant<em> </em>subsequent<em> line? </em>Obviously<em>.</p>
<p></em>Ought  to<em> </em>you&#8217;ve<em> to </em>squander<em> the </em>power<em> figuring that out? </em>Completely<em> not.</p>
<p></em>Including<em> curly braces </em>provides<em> </em>a  couple of<em> lines, </em>however  it<em> clarifies the </em>declaration<em> immensely, even </em>using  the<em> odd indentation:<br />
</em>see<em> plaincopy to clipboardprint?<br />
&lt;?php</p>
<p>$ foo = 8;</p>
<p>if( $  foo&lt;10 )<br />
</em><br />
if(  $ foo&gt;5 )</p>
<p>echo  &#8220;Greater than 5!&#8221;;</p>
<p>else</p>
<p>echo  &#8220;Less than 5!&#8221;;</p>
<p><em><br />
else<br />
</em><br />
echo  &#8220;Greater than 10!&#8221;;<br />
<em><br />
echo &#8221;<br />
</em>An  additional<em> </em>be  aware<em>.&#8221;;</p>
<p></em>Sure<em>, </em>it  is<em> </em>a  great<em> </em>factor<em> </em>to  help keep<em> your code concise, </em>although  not<em> </em>in  the<em> </em>cost<em> of clarity. </em>It  is<em> </em>well  worth the<em> </em>additional<em> lines </em>to  make sure<em> </em>nobody<em> </em>needs  to<em> bang their head </em>in  opposition to<em> a keyboard </em>attempting  to<em> sift </em>via<em> your code.<br />
</em>You  do not<em> </em>Adhere  to<em> a Coding </em>Regular<em></p>
<p></em>Select<em> </em>a  regular<em> and </em>stay  with<em> it.</p>
<p></em>Obtaining<em> </em>adorable<em> </em>together  with your<em> formatting </em>may<em> </em>fulfill<em> your </em>creative<em> urges, </em>however  it<em> does no </em>great<em> for </em>anybody<em>. </em>Select<em> </em>a  regular<em> (I </em>suggest<em> the PEAR coding </em>regular<em>)  and </em>stay  with<em> it. </em>Everybody<em> will </em>thanks<em>.  (</em>Such  as<em> </em>your  self<em>, someday.)</p>
<p></em>Believe  in<em> me. </em>I  used to be<em> that </em>man<em> </em>as  soon as<em> &#8211; I </em>desired  to<em> </em>possess  a<em> &#8220;signature style&#8221; &#8211; and I wasted </em>lots  of<em> </em>hrs<em> </em>repairing<em> my atrocious formatting </em>later  on<em> on. </em>There  is<em> a </em>time  for you to<em> be </em>various<em> </em>along  with a<em> </em>time  for you to<em> </em>get  it done<em> like </em>everybody<em> else.</p>
<p></em>With  regards to<em> programming, </em>consider<em> it like a spoken language. Grammar and punctuation exist </em>to  get a<em> </em>cause<em>:  so </em>we  are able to<em> </em>obviously<em> </em>comprehend<em> </em>one  another<em> </em>once  we<em> </em>create<em> </em>issues<em> down. </em>Consider<em> coding </em>requirements<em> like a geeky </em>edition<em> of Strunk &amp; White&#8217;s Elements of </em>Design<em> &#8211; following the guidelines means people </em>comprehend<em> what </em>you  are<em> </em>attempting  to<em> say, not that </em>you  are<em> a boring person.<br />
You Duplicate Code</p>
<p></em>You  are<em> doing it </em>incorrect<em>.</p>
<p>Try  to </em>take  a look at<em> </em>each  and every<em> </em>one<em> piece of your app as something </em>which  will<em> need to change </em>sooner  or later<em>. If it does, will </em>you&#8217;ve<em> to update more than </em>1<em> file? </em>In  the event you<em> answered </em>sure<em>, </em>it  is<em> </em>time  for you to<em> reevaluate how you </em>create<em> code.</p>
<p>If you&#8217;ve </em>received<em> code doing the same </em>factor<em> in more than </em>1<em> place </em>inside  your<em> app, </em>you  are<em> doing it </em>incorrect<em>.<br />
</em>You  do not<em> </em>Adhere  to<em> a </em>Advancement<em> Pattern</p>
<p></em>You  need to<em> </em>usually<em> </em>possess  a<em> structure when you code.</p>
<p></em>You  need to<em> </em>usually<em> </em>possess  a<em> structure when you code. I </em>do  not<em> </em>imply<em> to imply that you need </em>to  become<em> following the MVC pattern or something equally rigid, but I do </em>imply<em> that </em>you  need to<em> know how to classify components and where they </em>ought  to<em> go.</p>
<p>By following a logical </em>advancement<em> pattern, many decisions become automatic, and </em>somebody<em> coming into your code doesn&#8217;t </em>need  to<em> guess </em>a  lot<em> when looking </em>to  get a<em> certain functionality </em>inside  your<em> codebase.</p>
<p>It doesn&#8217;t </em>consider<em> long, and it really will clarify your apps </em>inside  a<em> big way.<br />
</em>You  are<em> Too Clever for Your Own </em>Great<em></p>
<p>The  simplest solution </em>is  generally<em> the most appropriate</p>
<p></em>There  is<em> a </em>good<em> line between a crafty solution and an overcomplicated </em>1<em>.</p>
<p></em>It  is<em> </em>usually<em> tempting to try out some sweet new trick you&#8217;ve learned, but we </em>need  to<em> resist the urge to force a complex solution into a space where a  simple </em>1<em> is sufficient.</p>
<p>On a basic level, the simplest solution </em>is  generally<em> the most appropriate. </em>You  are<em> </em>attempting  to<em> get from </em>stage<em> A to </em>stage<em> B &#8211; taking a detour </em>via<em> </em>stage<em> Awesome is fun, but really doesn&#8217;t add any benefits.</p>
<p>Your super-sweet  solution does, however, pose a problem in which </em>somebody<em> else may not have seen that particular solution and will just get </em>misplaced<em>. </em>It  is<em> not </em>simply  because<em> they&#8217;re not as </em>intelligent<em> </em>when  you<em>, either; </em>it  is<em> likely </em>simply  because<em> they didn&#8217;t see that particular </em>write-up<em> or weren&#8217;t </em>attempting  to<em> force a square concept into a round problem.</p>
<p></em>Do  not<em> dumb </em>your  self<em> down, but remember to avoid overcomplicating </em>issues<em> &#8220;just &#8217;cause.&#8221;<br />
</em>You  are<em> a Wang</p>
<p>Avoid actively making your code hard to </em>comprehend<em> at all costs.</p>
<p>When </em>I  used to be<em> </em>initial<em> </em>obtaining<em> into </em>advancement<em>,  I worked with a </em>man<em> that was a self-proclaimed &#8220;expert&#8221; programmer. Whenever I had a question about  a concept, he </em>by  no means<em> gave me a straight </em>solution<em>;  in order to get </em>the  solution<em> to my original question, I had to </em>solution<em> a couple preliminary questions to &#8220;prove you can handle </em>the  solution<em>.&#8221;</p>
<p>This </em>man<em> was also really </em>great<em> at writing code that was cryptic, obfuscated, and just generally  confusing.</p>
<p>Files like his are the result of programmers who </em>believe<em> that they need to make their code hard to </em>study<em> in order to &#8220;keep the idiots out.&#8221;</p>
<p>The general philosophy behind this  tends </em>to  become<em>, &#8220;If </em>you  are not<em> </em>intelligent<em> enough to </em>comprehend<em> this code, you shouldn&#8217;t be in it in the </em>initial<em> place.&#8221;</p>
<p>This </em>is  really a<em> deeply misguided and anti-social </em>method<em> to programming. </em>It  is<em> a very elitist way of looking at </em>issues<em>,  and it shows </em>the<em> programmer has </em>misplaced<em> touch with his beginner roots, when he himself needed help.</p>
<p>Avoid  actively making your code hard to </em>comprehend<em> at all costs. It doesn&#8217;t make you any cooler or smarter, and it doesn&#8217;t bolster  respect. It just </em>tends  to make<em> you a wang.<br />
Dude, What Are You Talking  About?</p>
<p></em>In  the event you<em> stop learning, then the </em>tasks<em> you work on are stuck in whatever time period you decided to settle.</p>
<p>In  addition to the shortcuts and general laziness above, </em>an  additional<em> </em>factor<em> that </em>may  be<em> holding you back </em>is  really a<em> lack of continued learning and forward  progress.</p>
<p>Technology </em>is  not<em> changing </em>simply  because<em> the community at large is bored and we decided to redecorate;  most new technologies emerge to more efficiently and easily solve existing  problems. Choosing to ignore progress is choosing to </em>begin<em> the slow process of marginalizing your skillset.</p>
<p>Here are </em>a  couple of<em> </em>issues<em> </em>we  are able to<em> all stop doing to </em>make  certain<em> that our skillsets are up-to-date, all </em>with  out<em> having to give up our weekends.<br />
</em>You  are<em> </em>Attempting  to<em> </em>Get  it done<em> All </em>Your  self<em></p>
<p>Find out which of these programmers </em>possess  a<em> similar </em>method<em> and let them fill you in on the big news.</p>
<p>You can&#8217;t </em>maintain<em> up </em>using  the<em> </em>entire<em> community. As </em>anybody<em> who&#8217;s ever tried </em>to  help keep<em> up with a subscription to 200+ tech blogs will tell you, it  simply can&#8217;t be </em>carried  out<em> within a reasonable timeframe.</p>
<p>Fortunately, there are </em>these<em> within the community who dedicate their </em>time  for you to<em> watching the progression of technology and reporting their  findings. </em>In  the event you<em> </em>consider<em> the </em>time  for you to<em> find out which of these programmers has a similar </em>method<em> and </em>design<em>,  you can let them fill you in on the big news.</p>
<p>Watching 2-5 of these  &#8220;early adopter&#8221; type bloggers can be more beneficial than subscribing to </em>each  and every<em> tech blog you come across for several reasons:<br />
</em>In  the event you<em> </em>believe  in<em> their opinion, they&#8217;ll be screening technologies for you.<br />
If a  technology pops up on more than </em>1<em> of these blogs, you know </em>you  need to<em> at least </em>consider<em> </em>a  couple of<em> minutes to learn more about it </em>simply  because<em> </em>it  is<em> obviously popular.<br />
</em>Frequently<em>,  these blogs will feature a quick intro tutorial, which can save you the headache  of starting from zero with a new technology.</p>
<p>Among the PHP bloggers I </em>believe  in<em> are David Walsh and Chris Shiflett.<br />
</em>You  are not<em> </em>From<em> Your Comfort Zone</p>
<p>I simply </em>imply<em> to suggest that you&#8217;ll feel more fulfilled as a programmer and see your talents  progress more and more </em>in  the event you<em> </em>select<em> to </em>usually<em> be looking to the </em>subsequent<em> level of programming.</p>
<p>If </em>you  are not<em> doing something that challenges you, something is </em>incorrect<em>.  Finding new challenges within </em>tasks<em> is most of what </em>tends  to make<em> programming rewarding (or at least it </em>ought  to<em> be).</p>
<p>Try asking </em>your  self<em> the following questions when </em>you  begin<em> looking at new </em>tasks<em>:<br />
Is  there a new technology that interests me that applies here?<br />
Have I learned </em>of  the<em> </em>much  better<em> way </em>to  complete<em> this since the </em>final<em> time I took on a </em>undertaking<em> like this?<br />
Is there a best practice I need to enforce that I could </em>make  certain<em> to </em>adhere  to<em> throughout this </em>undertaking<em>?</p>
<p></em>Maintain<em> in mind: </em>I  am<em> not talking about doing anything grossly complex, here.</p>
<p>It  can be as simple as remembering to add Docblocks to your objects, or as complex  as making your app compatible with XMLRPC so </em>it  is<em> easier for users to post updates.</p>
<p>Just try </em>to  not<em> settle in and convince </em>your  self<em> you&#8217;ve learned </em>every  thing<em> </em>you  are<em> going to learn. </em>That  is<em> when it&#8217;ll </em>begin<em> </em>obtaining<em> ugly for you.<br />
</em>You  are not<em> Sharing</p>
<p></em>Usually<em> discuss your code </em>together  with your<em> fellow programmers.</p>
<p>The best way to improve </em>would  be to<em> discuss your code </em>together  with your<em> fellow programmers. This can be </em>carried  out<em> </em>via<em> </em>numerous<em> avenues: if </em>you  are<em> feeling particularly outgoing, </em>create<em> a tutorial or release an open-source </em>undertaking<em>; </em>in  the event you<em> </em>do  not<em> feel up to something of that scale, </em>perhaps<em> you could hang out on a community forum and offer help to the  newcomers.</p>
<p>&#8220;How does helping the noobs help me progress?&#8221; you ask. </em>Generally<em>, </em>in  the event you<em> post a solution </em>that  can<em> be optimized, other experienced programmers are going to hop in  and offer tweaks. So this </em>method<em> </em>is  really a<em> double-whammy of awesomeness: </em>you  are not<em> only helping progress the community by offering your knowledge  to beginners, but </em>you  are<em> sharpening your own skillset by hanging your chops out for </em>everybody<em> to see and help you develop.<br />
</em>You  do not<em> Have Any Side </em>Tasks<em></p>
<p></em>In  the event you<em> want to get into something new and cool </em>that  is<em> a bit too involved to </em>place<em> into a real </em>undertaking<em>,  the best way to learn </em>would  be to<em> </em>begin<em> a side </em>undertaking<em> that uses said technique.</p>
<p>That way, you can progress at your own pace, </em>inside  your<em> free time, and </em>by  no means<em> risk missing a deadline or &#8220;doing it </em>incorrect<em>.&#8221;<br />
We&#8217;re  All Guilty</p>
<p>If we&#8217;re doing it right, we </em>ought  to<em> </em>usually<em> be improving. And logic tells us that if we&#8217;re </em>much  better<em> now, then we were worse </em>prior  to<em>. And if we </em>adhere  to<em> that line of reasoning back far enough, there was a </em>stage<em> where we were terrible.</em><em><br />
</em></div>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-news/why-you-might-be-a-crap-php-programmer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hey! PHP Developers make your code secure!</title>
		<link>http://www.phpide.com/php-tutorials/hey-php-developers-make-your-code-secure/</link>
		<comments>http://www.phpide.com/php-tutorials/hey-php-developers-make-your-code-secure/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 19:08:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[php security]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=398</guid>
		<description><![CDATA[PHP is arguably the most potent of all open-source programming languages. No longer used solely for web pages, it truly is turning out to be an more and more popular device for stand-alone applications and corporate purposes. In spite of all its electrical power and versatility, the PHP framework is far from protected. The a [...]]]></description>
			<content:encoded><![CDATA[<div>
<p><em>PHP is arguably </em>the  most<em> </em>potent<em> of all open-source programming languages. </em>No  longer<em> </em>used<em> </em>solely<em> for </em>web  pages<em>, </em>it  truly is<em> </em>turning  out to be<em> an </em>more  and more<em> </em>popular<em> </em>device<em> for stand-alone </em>applications<em> and </em>corporate<em> </em>purposes<em>. </em>In  spite of<em> all its </em>electrical  power<em> and </em>versatility<em>,  the PHP framework is </em>far<em> from </em>protected<em>.  The </em>a  great number of<em> </em>amount  of<em> </em>prosperous<em> hacks on </em>well-known<em> </em>world  wide web<em> </em>purposes<em> </em>including<em> Drupal, Joomla and WordPress serve as </em>strong<em> </em>evidence<em>. </em>In  this<em> </em>document<em>, </em>we  are going to<em> go </em>through<em> </em>several  of the<em> most </em>major<em> </em>protection<em> </em>difficulties<em> </em>to  aid<em> </em>reinforce<em> your shared, VPS or </em>devoted<em> </em>internet  hosting<em> </em>setting<em><span id="more-398"></span></em></p>
<p><em> </em><em></em><strong>Harmful<em> PHP </em>Features</strong><em></em></p>
<p><em> </em><em>All </em>possibly<em> </em>risky<em> PHP </em>features<em> </em>should  be<em> disabled and </em>never  ever<em> </em>applied<em> </em>except<em> </em>unquestionably<em> </em>vital<em>. </em>3<em> that pose </em>the  greatest<em> threats to </em>safety<em> are “passthru”, “EVAL” and “shell_ exec.” These </em>features<em> </em>is  often<em> disabled by </em>modifying<em> the “disable_functions” </em>worth<em> </em>from  the<em> “php.ini” file. EVAL is </em>conceivably<em> </em>essentially  the most<em> </em>vulnerable<em> of all </em>since<em> it </em>enables<em> the execution of remote PHP code. If </em>utilized  in<em> conjunction </em>having  an<em> insecure </em>world-wide<em> </em>value<em>,  this </em>unique<em> </em>purpose<em> </em>can  lead to<em> a </em>potentially<em> catastrophic </em>protection<em> breach. </em>Mainly  because<em> </em>apps<em> </em>like<em> ImageMagick </em>require<em> shell_exec, </em>you&#8217;ll  want to<em> </em>carry  out<em> some </em>investigation<em> </em>to  search out<em> out which </em>features<em> are </em>needed<em> </em>before<em> disabling them.</em></p>
<p><em><strong>Remote URL Injection</strong></p>
<p></em><em>When enabled </em>on  the<em> server, the “allow_url_fopen” </em>choice<em> permits file </em>capabilities<em> like “file_get_contents()”, which could </em>enable<em> </em>info<em> </em>being<em> retrieved from </em>destinations<em> </em>for  example<em> a remote </em>web  page<em> or FTP </em>connection<em>. </em>Because<em> </em>a  typical<em> PHP configuration has this </em>function<em> enabled by default, </em>it  is actually<em> </em>really<em> </em>recommended<em> that it be manually disabled </em>to  stop<em> </em>probably<em> </em>dangerous<em> code exploits. allow_url_fopen </em>is  very<em> </em>rarely<em> </em>applied<em>, </em>as  a result<em>, </em>you  should be<em> </em>ready<em> to disable it and </em>still<em> </em>benefit  from the<em> </em>entire<em> </em>functionality<em> </em>of  your<em> </em>web  site<em>.</em></p>
<p><em><strong>Insecure Code</strong></p>
<p></em><em></em>There  are many<em> </em>aspects<em> that make PHP </em>among  the<em> most </em>versatile<em> platforms for </em>world  wide web<em> </em>progress<em>. </em>Nevertheless<em>, </em>it  really is<em> this </em>incredibly<em> </em>overall  flexibility<em> </em>that  often<em> </em>leads  to<em> </em>protection<em> gaps </em>that  could<em> </em>bring  about<em> a compromised server or </em>web  site<em>. </em>This  is<em> </em>especially<em> </em>accurate<em> </em>with  the<em> </em>widely<em> </em>employed<em> </em>web<em> </em>programs<em> coded </em>within  the<em> PHP language. </em>Several  of<em> today’s </em>hottest<em> </em>information<em> </em>management<em> </em>systems<em> have bugs and </em>security<em> holes </em>inside  the<em> supported plugins </em>and  also<em> the core code </em>alone<em>. </em>For  this reason<em>, </em>you&#8217;ll  want to<em> </em>ensure  it is<em> a priority to </em>operate<em> </em>probably  the most<em> </em>current<em> and </em>secure<em> </em>versions<em> of PHP scripts and </em>stay<em> weary of plugins and modules. </em>Actually<em>, </em>until<em> their </em>functionality<em> is </em>definitely<em> </em>essential<em>, </em>you&#8217;ll  want to<em> </em>look  at<em> </em>to  help keep<em> your </em>website<em> </em>software<em> platforms </em>simple<em> with as </em>few<em> extensions </em>as  you can<em>.</em></p>
<p><em> </em><em></em><strong>Summary</strong><em></em></p>
<p><em> </em><em>Programmers </em>nowadays<em> are </em>faced<em> with </em>sizeable<em> </em>challenges<em> </em>because  of the<em> </em>fact<em> </em>the<em> </em>record<em> of </em>possibilities<em> PHP </em>protection<em> </em>challenges<em> is </em>fairly<em> </em>intensive<em>.  Even </em>worse<em>,  the </em>listing<em> continues to </em>develop<em> </em>with  the<em> release </em>of  every<em> new </em>version<em>. </em>That  is why<em> </em>it  is just a<em> developer’s </em>task<em> to </em>acquire<em> </em>the  mandatory<em> </em>actions<em> </em>to  guarantee<em> their code is </em>safe<em> </em>as  you possibly can<em>. </em>This  could<em> be </em>performed<em> by </em>clever<em> coding, only </em>applying<em> </em>required<em> </em>capabilities<em> and </em>making  use of<em> </em>up  to date<em> PHP scripts. </em>Additionally<em>, </em>much  better<em> </em>defense<em> </em>can  be<em> assured by </em>carrying  out<em> </em>enterprise<em> </em>that  has a<em> </em>hosting<em> </em>agency<em> who </em>makes<em> </em>security<em> a priority. </em>So  that you can<em> </em>give  you<em> </em>protected<em> </em>setting<em> for PHP </em>projects<em>,  their </em>hosting<em> platform </em>ought  to<em> be </em>properly<em> configured. The </em>combo<em> of an </em>inadequate<em> PHP/web server </em>is  one of the<em> </em>big<em> </em>triggers<em> of </em>productive<em> </em>protection<em> breaches.</em></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/hey-php-developers-make-your-code-secure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to optimize and speed up your PHP script</title>
		<link>http://www.phpide.com/php-tutorials/how-to-optimize-and-speed-up-your-php-script/</link>
		<comments>http://www.phpide.com/php-tutorials/how-to-optimize-and-speed-up-your-php-script/#comments</comments>
		<pubDate>Fri, 19 Aug 2011 19:03:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[optimize php scripts]]></category>
		<category><![CDATA[php tutorial]]></category>
		<category><![CDATA[php tutorials for beginners]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=402</guid>
		<description><![CDATA[This PHP tutorial will guide you into optimizing your PHP scripts to load and process quicker! PHP has two different functions which are usually used to output data to a client – echo and print. Echo is faster than print by about eight percent. Static is Better For those who can declare one thing to [...]]]></description>
			<content:encoded><![CDATA[<p>This PHP tutorial will guide you into optimizing your PHP scripts to load and process quicker!</p>
<p>PHP has two different functions which are usually used to output data to a client – echo and print. Echo is faster than print by about eight percent.</p>
<p><strong> Static is Better</strong></p>
<p>For  those who<em> can declare </em>one  thing<em> to be static, do it. A PHP script </em>will  be<em> served </em>at  the least<em> two to ten times slower by Apache than a static HTML page.  So, </em>attempt  to<em> use </em>extra<em> HTML pages and fewer server-side scripts. </em>When  you are<em> working in OOP, if it </em>could  be<em> a static </em>technique<em>,  declare it static. </em>This  may<em> </em>increase<em> your speed by a factor of </em>4<em>.<br />
</em></p>
<p><strong>Require() vs. Include()</strong></p>
<p>require<em>()  and </em>contain<em>()  are </em>pretty<em> </em>considerably<em> identical in </em>each  and every<em> way, except that </em>call  for<em> stops if the file is missing. </em>However<em>,  as far as performance is concerned, </em>there&#8217;s<em> </em>pretty<em> </em>little<em> </em>distinction<em>.  Also, whenever </em>probable<em>,  use </em>need<em>() </em>as  an alternative to<em> require_once(). </em>Utilizing<em> </em>require<em> is about a 3x to 4x speed-up over </em>using<em> require_once. Also, </em>vital<em> to know, require_once() is </em>high  priced<em>.<br />
</em></p>
<p><strong>Echoing Strings</strong></p>
<p>If  you<em> echoing strings </em>it&#8217;s<em> </em>basically<em> </em>faster<em> to separate them by a comma </em>as  opposed to<em> a dot. </em>On  the other hand<em>, </em>you  need to<em> know this only works with echo &#8211; which </em>is  actually a<em> function </em>which  can<em> take </em>a  number of<em> string arguments. Also, </em>make  an effort to<em> use echo&#8217;s </em>multiple<em> parameters </em>rather  than<em> string concatenation.<br />
</em></p>
<p><strong>Arrays and Single Character Functions</strong></p>
<p><em>If a function &#8211; like a string replacement function &#8211; will accept </em>both<em> arrays and single characters as arguments, and if your argument list </em>is  not<em> too </em>lengthy<em>, </em>attempt<em> writing redundant replacement statements, </em>rather  than<em> a line of code that accepts arrays as search and replace  arguments.<br />
</em></p>
<p><strong>Stick to the best standards of coding<br />
</strong></p>
<p>When  you<em> stick with coding standards </em>it&#8217;ll<em> make it </em>a  great deal<em> </em>less  difficult<em> for you to </em>have  an understanding of<em> other people&#8217;s code, and in return they&#8217;ll </em>essentially<em> </em>have  the ability to<em> </em>recognize<em> yours.<br />
</em></p>
<p><strong>Just more Cache!</strong></p>
<p>Try<em> </em>using<em> memchached, a high-performance memory object caching </em>program<em> that speeds up dynamic </em>web<em> applications by alleviating the database load. Your PHP scripts are recompiled </em>every  time<em> unless the scripts are cached. So, </em>make  certain<em> to install a PHP caching </em>item<em>. </em>This  will<em> </em>increase<em> your performance by 25-to-100% </em>for  the reason that<em> it removes compile times.</em></p>
<p><strong>Resources:</strong></p>
<p><a title="PHP tutorials for beginners" href="http://www.phpide.com/category/php-tutorials/">PHP tutorials for beginners</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-tutorials/how-to-optimize-and-speed-up-your-php-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Effective PHP Functions to Sort Arrays in PHP Development</title>
		<link>http://www.phpide.com/php-news/effective-php-functions-to-sort-arrays-in-php-development/</link>
		<comments>http://www.phpide.com/php-news/effective-php-functions-to-sort-arrays-in-php-development/#comments</comments>
		<pubDate>Wed, 17 Aug 2011 19:08:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP News]]></category>
		<category><![CDATA[Arrays]]></category>
		<category><![CDATA[php tutorial for beginners]]></category>
		<category><![CDATA[php tutorials]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=406</guid>
		<description><![CDATA[Array in PHP represents a map which assigns values to keys and will be handled as collection, queue, record (vector), stack, hash table, dictionary and other people. Array values are not minimal to a specific array and might be utilized as trees and multidimensional arrays. Sorting of arrays is usually a lengthy process and frequently [...]]]></description>
			<content:encoded><![CDATA[<p>Array in PHP represents a map which assigns values to keys and will be handled as collection, queue, record (vector), stack, hash table, dictionary and other people. Array values are not minimal to a specific array and might be utilized as trees and multidimensional arrays. Sorting of arrays is usually a lengthy process and frequently time consuming. PHP features we are about to mention enable PHP developer in India type them effortlessly for just about any PHP growth in India challenge. These features very easily enable a PHP developer to forge arrangement of elements within an array and rearrange them in numerous unique methods.<span id="more-406"></span></p>
<p>1) Very simple sorting : By far the most essential and simplest array sorting perform normally utilised in any PHP progress in India challenge is simple sorting. Working with this a PHP developer in India can sort the array from lowest values to highest values and even numerically or alphabetically and it is represented as type(). Re-sort the arrays by making use of rsort(), it is going to robotically rearrange the values.</p>
<p>two) Working with a Crucial to Kind : Employing keys is an uncomplicated alternative to re-sort associative arrays all over again from best to lowest. Focused PHP function for this is certainly ksort() and it maintains key-value correlation in the course of the method of sorting. A PHP developer in India can reverse sort by key making use of the ksort() operate.</p>
<p>3) Sorting by worth : If a venture for PHP development in India desires the array should be sorted applying value in place of critical then a PHP developer in India can make use of the sorting by worth purpose working with assort() rather than Ksort(). The identical is often reversed using arsort().</p>
<p>4) Natural-language sorting : An exquisite perform which might enable kind features while in the PHP improvement in India undertaking as if a human would do is the purely natural language sorting. The function works by using human logic rather than computational principles while sorting arrays. It truly is aptly termed natural language sorting. PHP builders in India can use the operate for his or her benefit when creating programs requiring greater level of logic.</p>
<p>5) Sorting by user-defined guidelines : Choose to sort arrays to make sure that they suit your person demands, you&#8217;ll be able to also try this applying PHP while using sorting by user-defined principles. PHP developer in India can try this by defining individual sorting algorithm which might be accomplished by producing personal comparison function and passing the same to usort(). Only point being careful about should be to make sure which the function returns a range below 0 if 1st argument would be to be considered less than the second and vis a versa.</p>
<p>One example is a PHP developer in India can build comparison using strlen() function to check the quantity of characters in each and every string and then return a worth which can be a smaller amount or maybe more in value as defined by the sorting.</p>
<p>6) Multidimensional sorting : For operating on complicated projects for PHP development in India which requires a comparatively complex sorting a PHP developer in India can use multidimensional sorting. The perform is represented applying array_multisort() and it is hugely admired to get the most impressive. It could be utilised for different factors.</p>
<p><strong>Resources:</strong></p>
<p><a title="PHP tutorials for beginners" href="http://www.phpide.com/category/php-tutorials/">PHP tutorials for beginners</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-news/effective-php-functions-to-sort-arrays-in-php-development/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crucial things prior to hiring a PHP developer for your website</title>
		<link>http://www.phpide.com/php-news/crucial-things-prior-to-hiring-a-php-developer-for-your-website/</link>
		<comments>http://www.phpide.com/php-news/crucial-things-prior-to-hiring-a-php-developer-for-your-website/#comments</comments>
		<pubDate>Tue, 16 Aug 2011 19:09:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP News]]></category>
		<category><![CDATA[php developer]]></category>

		<guid isPermaLink="false">http://www.phpide.com/?p=417</guid>
		<description><![CDATA[It really is great news that the waves of recession have blown over, much towards the delight of companies throughout the globe. But what the economic downturn has taught us needs to be remembered, the recession has helped us master that no company, large or small, can assume to observe a lenient method. What&#8217;s more, [...]]]></description>
			<content:encoded><![CDATA[<p>It really is great news that the waves of recession have blown over, much towards the delight of companies throughout the globe. But what the economic downturn has taught us needs to be remembered, the recession has helped us master that no company, large or small, can assume to observe a lenient method. What&#8217;s more, each enterprise should try its finest to cut back its expenses and one among these strategies is often hiring a PHP developer for the website. Permit us study how one can save many thousands by wisely selecting offshore PHP development.<span id="more-417"></span></p>
<p>In order to conserve a significant amount of cash, lots of organizations currently are earning the choice of employing offshore PHP developers. One of many most significant factors why each and every business enterprise need to opt for focused PHP developers is always that a trusted developer can provide a far more genuine and attractive feel in your site, which can generate qualified sales opportunities and enable in creating sales and profits now and in the future.</p>
<p>Since we now have understood why devoted PHP developers are reliable by a single and all, permit us now shift our concentration to critical elements previous to hiring a PHP developer to your webpage. Ahead of you retain PHP builders or retain the services of PHP programmer, it is important for you personally to very first discover the web site or task necessities so it will become much easier in your case to acquire the proper match regarding PHP application developers. If you would like to outsource PHP development, you might want to come across an organization specializing in growth of PHP. Several of the critical elements and credentials that the likely PHP development firm must have are as follows:</p>
<p>The organization will need to have manpower specializing in state-of-the-art platforms and technologies for instance MySQL, JavaScript, AJAX, and SEO-based semantic HTML coding. It should have enough knowledge in developing and implementing fulfilling tactics which can perform effectively for firms, through a timeframe, and beneath evolving conditions. Also to all these factors, the business needs to be ready to respect time deadlines and need to have produced world-class PHP projects exceeding customer expectations beneath strict deadlines. One of many greatest possibilities for your enterprise could be outsourcing PHP advancement to India. This really is simply just since India is pivotal in revolutionizing the world of PHP development since the previous numerous many years. In addition, your enterprise gets finish through all PHP progress routines even soon after delegating (outsourcing) get the job done to experts when it decides to hire PHP developer India.</p>
<p>Permit us study far more about positive aspects of outsourcing PHP improvement to India. You may hire PHP builders at just about 1/10th on the price tag that you simply would have incurred if opted for producing a PHP crew at your individual workplace. Right after you seek the services of PHP developer, India&#8217;s outsourcing policies enable your small business help you save hundreds of thousands in taxes and benefits. Furthermore, PHP application developers of India are conscious of your most recent technologies and also have constantly lived up to the expectations in terms of the delivery of PHP solutions matching globe specifications.Within the above statements, it can be evident that it really is good to hire PHP developers in particular from India somewhat than building your individual PHP crew because the former provides affordability, reliability, earth class PHP options, and matches with throughout the world standards for your international acceptance.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpide.com/php-news/crucial-things-prior-to-hiring-a-php-developer-for-your-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

