<?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 Tutorials Code Snippets and Php Tips &#187; Short PHP Functions</title>
	<atom:link href="http://readytousesolutions.com/phpblog/category/short-php-functions/feed/" rel="self" type="application/rss+xml" />
	<link>http://readytousesolutions.com/phpblog</link>
	<description>PHP tutorials - Examples of the most useful scripts</description>
	<lastBuildDate>Thu, 23 Sep 2010 06:54:31 +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 Tutorial : Upper Case Characters</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-upper-case-characters/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-upper-case-characters/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 21:09:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[capitalize]]></category>
		<category><![CDATA[convert lowercase to uppercase]]></category>
		<category><![CDATA[php capitalization]]></category>
		<category><![CDATA[php capitalize]]></category>
		<category><![CDATA[php character capitalize]]></category>
		<category><![CDATA[php letters to uppercase]]></category>
		<category><![CDATA[php upper case]]></category>
		<category><![CDATA[php upper case characters]]></category>
		<category><![CDATA[upper case]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=163</guid>
		<description><![CDATA[Another week, another fresh post over here. I will write shortly about two ways on how to make characters/letters upper case (capitalize). One way its strtoupper (string to upper) which converts all string, and the second its for first character &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-upper-case-characters/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Another week, another fresh post over here. I will write shortly about two ways on how to make characters/letters upper case (capitalize). One way its strtoupper (string to upper) which converts all string, and the second its for first character only function ucfirst(). Here comes the example:</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$capitalizeString <span class="phpOperator">=</span> <span class="phpFunction">strtoupper</span><span class="phpOperator">(</span><span class="phpString">"my string"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//will<span class="phpKeyword"> return </span>MY STRING
</span>
$capitalizeFirst <span class="phpOperator">=</span> <span class="phpFunction">ucfirst</span><span class="phpOperator">(</span><span class="phpString">"my"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//returns My
</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-upper-case-characters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Exit and Die Functions</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-exit-and-die-functions/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-exit-and-die-functions/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 20:54:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[die]]></category>
		<category><![CDATA[exit]]></category>
		<category><![CDATA[php die]]></category>
		<category><![CDATA[php exit]]></category>
		<category><![CDATA[stop]]></category>
		<category><![CDATA[stop script]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=152</guid>
		<description><![CDATA[hi, I have two mins to write about those two very basic functions which will make your script to stop completely, the code will not be interpreted anymore before the line where says exit or die. have some tests (first &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-exit-and-die-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>hi,<br />
I have two mins to write about those two very basic functions which will make your script to stop completely, the code will not be interpreted anymore before the line where says exit or die. have some tests (first one will exit without any notice and with the second one you can show a message to the browser before stoping the script)</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="htmlText">
print </span><span class="phpString">"something"</span><span class="phpText">;</span>
<span class="phpFunction">exit</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="htmlText">
print </span><span class="phpString">"will not print"</span><span class="phpText">;</span>
<span class="phpComment">//or like this which will show a message too
</span><span class="htmlText">print </span><span class="phpString">"something<span class="phpKeyword"> else"</span></span><span class="phpText">;</span>
<span class="phpFunction">die</span><span class="phpOperator">(</span><span class="phpString">"message"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-exit-and-die-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Get file extension</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-get-file-extension/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-get-file-extension/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 20:08:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[file extension]]></category>
		<category><![CDATA[get file extension]]></category>
		<category><![CDATA[php  extension]]></category>
		<category><![CDATA[php  file extension]]></category>
		<category><![CDATA[php get file extension]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=93</guid>
		<description><![CDATA[With the next three lines of php code you will be able to get a file extension. &#60;?php $file = "somefile.gif"; $ext = end(explode('.', $file)); print "Your file extension is $ext"; ?&#62;]]></description>
			<content:encoded><![CDATA[<p>With the next three lines of php code you will be able to get a file extension.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$file <span class="phpOperator">=</span> <span class="phpString">"somefile.gif"</span><span class="phpText">;</span>
$ext <span class="phpOperator">=</span> <span class="phpFunction">end</span><span class="phpOperator">(</span><span class="phpFunction">explode</span><span class="phpOperator">(</span><span class="phpString">'<span class="phpOperator">.</span>'</span>, $file<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="htmlText">
print </span><span class="phpString">"Your file extension is $ext"</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<pre class="php php" style="font-family: monospace;"><span style="color: #000088;">
</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-get-file-extension/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Valid email checking script</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-valid-email-checking-script/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-valid-email-checking-script/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 17:34:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[check email]]></category>
		<category><![CDATA[check valid email]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[email address validation]]></category>
		<category><![CDATA[email checking]]></category>
		<category><![CDATA[email checking script]]></category>
		<category><![CDATA[email validation]]></category>
		<category><![CDATA[mail check]]></category>
		<category><![CDATA[valid email]]></category>
		<category><![CDATA[valid email checking]]></category>
		<category><![CDATA[valid mail]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=79</guid>
		<description><![CDATA[Hi, Do you have any newsletters, contact forms or other pages where you require an email address ? If so, did you ever thought that someone might type &#8220;asd&#8221;, &#8220;452&#8243; and other dummy words instead of a valid email address? &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-valid-email-checking-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
Do you have any newsletters, contact forms or other pages where you require an email address ? If so, did you ever thought that someone might type &#8220;asd&#8221;, &#8220;452&#8243; and other dummy words instead of a valid email address? Huh, for that I built an email validation script which checks for those things.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpFunctionKeyword">function</span><span class="htmlText"> validMail </span><span class="phpOperator">(</span>$email,$link<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">	if<span class="phpOperator">(</span></span><span class="phpOperator">!</span><span class="phpFunction">eregi</span><span class="phpOperator">(</span><span class="phpString">"^<span class="phpOperator">[</span>a-z0-9_<span class="phpOperator">]</span><span class="phpOperator">+</span>@<span class="phpOperator">[</span>a-z0-<span class="phpNumber">9</span>\-<span class="phpOperator">]</span><span class="phpOperator">+</span>\<span class="phpOperator">.</span><span class="phpOperator">[</span>a-z\-\<span class="phpOperator">.</span><span class="phpOperator">]</span><span class="phpOperator">+</span>$"</span>,$email<span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
		<span class="htmlText">print </span><span class="phpString">"Email address appears to be invalid<span class="phpOperator">&lt;</span>br /<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
		<span class="htmlText">print </span><span class="phpString">"Go back <span class="phpOperator">&lt;</span>a href=\"</span>$link\<span class="phpString">" title=\"</span>inapoi\<span class="phpString">"<span class="phpOperator">&gt;</span><span class="htmlText">click aici</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
		<span class="phpFunction">exit</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
	<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>You will need to pass two arguments :<br />
1) $email field<br />
2) $link to go back if email is invalid<br />
Right like here</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
$email <span class="phpOperator">=</span> <span class="phpString">"abcdef"</span><span class="phpText">;</span>
<span class="htmlText">
validMail</span><span class="phpOperator">(</span>$email, <span class="phpString">"complete-form<span class="phpOperator">.</span>php"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-valid-email-checking-script/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Function To Refresh a Page</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-function-to-refresh-a-page/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-function-to-refresh-a-page/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 12:43:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[php function to refresh page]]></category>
		<category><![CDATA[php refresh]]></category>
		<category><![CDATA[refresh in a number of given seconds]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=14</guid>
		<description><![CDATA[Well, This php function uses the html meta tag and its refresh attribute. I use it because I can easily estabilish how many seconds to wait before refreshing the page : nice, isn&#8217;t it? There is already a php function &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-function-to-refresh-a-page/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well,</p>
<p>This php function uses the html meta tag and its refresh attribute. I use it because I can easily estabilish how many seconds to wait before refreshing the page : nice, isn&#8217;t it?</p>
<p>There is already a php function which refreshes a page, but there isn&#8217;t a way to pass the number of seconds needed before refreshes, it&#8217;s just refreshes the page when the php engine goes to the line of code.</p>
<p>Here is the function :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//<span class="phpFunctionKeyword">function</span> to refresh a page in a number of seconds
</span>
<span class="phpFunctionKeyword">function</span><span class="htmlText"> refreshPage</span><span class="phpOperator">(</span>$destination, $seconds<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="htmlText">
print </span><span class="phpString">"<span class="phpOperator">&lt;</span>meta http-equiv<span class="phpOperator">=</span>\"</span>refresh\<span class="phpString">" content<span class="phpOperator">=</span>\"</span>$seconds<span class="phpText">;</span> url=$destination\<span class="phpString">"<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-function-to-refresh-a-page/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Tutorial : Function &#8211; Filter unwanted words</title>
		<link>http://readytousesolutions.com/phpblog/php-tutorial-function-filter-unwanted-words/</link>
		<comments>http://readytousesolutions.com/phpblog/php-tutorial-function-filter-unwanted-words/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 12:06:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Short PHP Functions]]></category>
		<category><![CDATA[custom php function]]></category>
		<category><![CDATA[filter unwanted words]]></category>
		<category><![CDATA[php filter]]></category>
		<category><![CDATA[php function]]></category>
		<category><![CDATA[php tutorial]]></category>

		<guid isPermaLink="false">http://www.crivionweb.com/phpblog/?p=3</guid>
		<description><![CDATA[Hello, I finded it usefull to build a simple and maximum 10 lines of code php function which can be used in filtering words that you wouldn&#8217;t want to appear on your website, forum, guestbook, comments, etc. The most common &#8230; <a href="http://readytousesolutions.com/phpblog/php-tutorial-function-filter-unwanted-words/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>I finded it usefull to build a simple and maximum 10 lines of code php function which can be used in filtering words that you wouldn&#8217;t want to appear on your website, forum, guestbook, comments, etc.</p>
<p>The most common way where is to use it within a html form, validating an input, textarea element, etc.</p>
<p>The code is built and commented below :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//call the special word which builds a<span class="phpKeyword"> new </span><span class="phpFunctionKeyword">function</span>
</span>
<span class="phpComment">//custom php <span class="phpFunctionKeyword">function</span> and give it a nice name
</span><span class="phpFunctionKeyword">function</span><span class="htmlText"> filterMe</span><span class="phpOperator">(</span>$whatToFilter, $listOfUnwantedWords<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpKeyword">
foreach </span><span class="phpOperator">(</span>$listOfUnwantedWords<span class="phpKeyword"> as </span>$value<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
if </span><span class="phpOperator">(</span><span class="phpFunction">preg_match</span><span class="phpOperator">(</span><span class="phpString">"/$value/i"</span>, <span class="phpString">"$whatToFilter"</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="htmlText">
print </span><span class="phpString">"You have used an unallowed word"</span><span class="phpText">;</span>
<span class="phpFunction">exit</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Usage of this php function to filter unwanted words : firstly, build an php array with unwanted words, then apply the function where you need it. Example :</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//create <span class="phpFunction">array</span> with not wanted words
</span>
$Unwanted <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"www"</span>, <span class="phpString">"mywebsite"</span>, <span class="phpString">"etc"</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//estabilish which given word to filter
</span>
$word <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'yourinput'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpComment">//<span class="phpFunctionKeyword">function</span> in action
</span>
<span class="htmlText">
filterMe</span><span class="phpOperator">(</span>$word, $Unwanted<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>Feel free to use it anywhere!</p>
]]></content:encoded>
			<wfw:commentRss>http://readytousesolutions.com/phpblog/php-tutorial-function-filter-unwanted-words/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

