<?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>Bracket &#8211; stoimen&#039;s web log</title>
	<atom:link href="/tag/bracket/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>on web development</description>
	<lastBuildDate>Tue, 13 Feb 2018 08:18:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.0.3</generator>
	<item>
		<title>Custom Routes with Zend_Controller_Router_Route</title>
		<link>/2010/04/20/custom-routes-with-zend_controller_router_route/</link>
		<comments>/2010/04/20/custom-routes-with-zend_controller_router_route/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 09:39:53 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[micro tutorial]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[zend framework]]></category>
		<category><![CDATA[Apache HTTP Server]]></category>
		<category><![CDATA[Bracket]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[controller]]></category>
		<category><![CDATA[Front Controller pattern]]></category>
		<category><![CDATA[index controller]]></category>
		<category><![CDATA[Latin alphabet]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Punctuation]]></category>
		<category><![CDATA[Typography]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web application frameworks]]></category>
		<category><![CDATA[World Wide Web]]></category>

		<guid isPermaLink="false">/?p=1458</guid>
		<description><![CDATA[Rewrite The Url? Actually this is really a common task to do. You&#8217;ve to rewrite the url to be more &#8220;user friendly&#8221;. To be more clear I&#8217;ll give you an example. Let&#8217;s imagine you have a index controller and an index action. Thus if you have to load an Id from the database at least &#8230; <a href="/2010/04/20/custom-routes-with-zend_controller_router_route/" class="more-link">Continue reading <span class="screen-reader-text">Custom Routes with Zend_Controller_Router_Route</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2010/06/16/zend-examples-get-parameters-default-value/" rel="bookmark" title="Zend Examples: GET Parameters Default Value">Zend Examples: GET Parameters Default Value </a></li>
<li><a href="/2009/10/27/zend-framework-custom-urls/" rel="bookmark" title="Zend Framework custom URLs">Zend Framework custom URLs </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2009/12/20/redirecting-with-zend-framework-part-2/" rel="bookmark" title="Redirecting with Zend Framework &#8211; part 2">Redirecting with Zend Framework &#8211; part 2 </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>Rewrite The Url?</h2>
<p>Actually this is really a common task to do. You&#8217;ve to rewrite the url to be more &#8220;user friendly&#8221;. To be more clear I&#8217;ll give you an example. Let&#8217;s imagine you have a index controller and an index action. Thus if you have to load an Id from the database at least with the build in <a title="Zend Framework" href="http://framework.zend.com/" target="_blank">Zend Framework</a> capabilities, you&#8217;ve to use this link:</p>
<pre>www.example.com/index/index/id/33949</pre>
<p>This is not good. It&#8217;s really bad. It will be great if you can use something like this:</p>
<pre>www.example.com/33949</pre>
<p>The solution in Zend Framework is called <a title="Zend_Controller_Router_Route" href="http://framework.zend.com/manual/en/zend.controller.router.html" target="_blank">Zend_Controller_Router_Route</a>. In a short snippet this will look like so:</p>
<pre lang="php" escaped="true">
$frontController-&gt;addRoute("my-route", new Zend_Controller_Router_Route("/:id",
    array("controller" =&gt; "index", "action" =&gt; "index", 'id' =&gt; 1),
    array('id' =&gt; '\d+')));
</pre>
<p>Here as you can see id is set to be 1. But don&#8217;t worry that&#8217;s not a hard code. The real work is done by the last parameter where the id is matched against a number value. Thus www.example.com/3 will be OK, but www.example.com/3a won&#8217;t.</p>
<h2>Important Note</h2>
<p>Don&#8217;t forget to add this rewrite rule in the .htaccess file.</p>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2010/06/16/zend-examples-get-parameters-default-value/" rel="bookmark" title="Zend Examples: GET Parameters Default Value">Zend Examples: GET Parameters Default Value </a></li>
<li><a href="/2009/10/27/zend-framework-custom-urls/" rel="bookmark" title="Zend Framework custom URLs">Zend Framework custom URLs </a></li>
<li><a href="/2010/06/23/bind-zend-action-with-non-default-view-part-2/" rel="bookmark" title="Bind Zend Action with Non-Default View &#8211; Part 2">Bind Zend Action with Non-Default View &#8211; Part 2 </a></li>
<li><a href="/2009/12/20/redirecting-with-zend-framework-part-2/" rel="bookmark" title="Redirecting with Zend Framework &#8211; part 2">Redirecting with Zend Framework &#8211; part 2 </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/04/20/custom-routes-with-zend_controller_router_route/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP if-else-endif Statements</title>
		<link>/2010/03/10/php-if-else-endif-statements/</link>
		<comments>/2010/03/10/php-if-else-endif-statements/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 08:12:22 +0000</pubDate>
		<dc:creator><![CDATA[Stoimen]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Bracket]]></category>
		<category><![CDATA[Computer programming]]></category>
		<category><![CDATA[Computing]]></category>
		<category><![CDATA[Cross-platform software]]></category>
		<category><![CDATA[Curly bracket programming languages]]></category>
		<category><![CDATA[Foreach]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[PHP programming language]]></category>
		<category><![CDATA[Procedural programming languages]]></category>
		<category><![CDATA[Scripting languages]]></category>
		<category><![CDATA[Smarty]]></category>
		<category><![CDATA[Software engineering]]></category>
		<category><![CDATA[Technology/Internet]]></category>
		<category><![CDATA[template systems]]></category>
		<category><![CDATA[typical web developer]]></category>

		<guid isPermaLink="false">/?p=1221</guid>
		<description><![CDATA[PHP: if A typical web developer knows exactly how a PHP if statement looks like: if ( expression ) { // if the expression was true proceed here } else { // there was a false expression } HTML mess with PHP When it comes to merge PHP and HTML the things are becoming ugly. &#8230; <a href="/2010/03/10/php-if-else-endif-statements/" class="more-link">Continue reading <span class="screen-reader-text">PHP if-else-endif Statements</span> <span class="meta-nav">&#8594;</span></a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2010/05/19/php-associative-arrays-coding-style/" rel="bookmark" title="PHP Associative Arrays Coding Style">PHP Associative Arrays Coding Style </a></li>
<li><a href="/2010/05/25/php-coding-style-large-if-statements/" rel="bookmark" title="PHP Coding Style: Large IF Statements">PHP Coding Style: Large IF Statements </a></li>
<li><a href="/2010/02/07/javascript-optimization-optimizing-if-statements/" rel="bookmark" title="JavaScript optimization. Optimizing IF statements.">JavaScript optimization. Optimizing IF statements. </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<h2>PHP: if</h2>
<p>A typical web developer knows exactly how a PHP if statement looks like:</p>
<pre lang="php">   if ( expression ) {
      // if the expression was true proceed here
   } else {
      // there was a false expression
  }
</pre>
<h2>HTML mess with PHP</h2>
<p>When it comes to merge PHP and HTML the things are becoming ugly. Indeed most of the template systems as Smarty are improved and developed to overcome this issue, however when working with a native PHP code with no template system or with template system where the PHP code is allowed the things are really bad.</p>
<p>Let me show this in a breve example. Image you have to show different formatted HTML depending on a PHP expression. Something like that</p>
<pre lang="php">
<?php if (expression) { ?>
<div class="message">OK. Your registration is successful</div>
<?php } else { ?>
<div class="error">Something went wrong! Please try again later! </div>
<?php } ?>
</pre>
<p>Now you can see how difficult to maintain this code is when it doesn&#8217;t make use of only one code of HTML markup. Imaging you&#8217;ve to print differently formatted tables! Indeed the PHP curly brackets are different to follow.</p>
<h2>PHP: the different IF syntax</h2>
<p>So there is a PHP syntax that tries to help you manage this. You can write more human readable code like this:</p>
<pre lang="php">
<?php if ( expression ) : ?>
<div>message goes here</div>
<?php endif ?>
</pre>
<p>Thus you get the ENDIF instead of only one curly bracket. That&#8217;s indeed readable enough. In fact you can use this syntax with any conditional or loop statement in PHP:</p>
<pre lang="php">
<?php foreach($array as $key => $val) : ?>
<div class="message"><?php echo $val ?></div><br />
<?php endforeach ?>
</pre>
<p>To return in the previous example the code above should be transformed in that:</p>
<pre lang="php">
<?php if ( expression ) : ?>
<div class="message">some message here!</div>
<?php else : ?>
<div class="error">some error here!</div>
<?php endif ?>
</pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="/2012/04/26/php-strings-dont-need-quotes/" rel="bookmark" title="PHP Strings Don&#8217;t Need Quotes">PHP Strings Don&#8217;t Need Quotes </a></li>
<li><a href="/2010/05/19/php-associative-arrays-coding-style/" rel="bookmark" title="PHP Associative Arrays Coding Style">PHP Associative Arrays Coding Style </a></li>
<li><a href="/2010/05/25/php-coding-style-large-if-statements/" rel="bookmark" title="PHP Coding Style: Large IF Statements">PHP Coding Style: Large IF Statements </a></li>
<li><a href="/2010/02/07/javascript-optimization-optimizing-if-statements/" rel="bookmark" title="JavaScript optimization. Optimizing IF statements.">JavaScript optimization. Optimizing IF statements. </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>/2010/03/10/php-if-else-endif-statements/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
