<?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>NewSourceMedia Blog &#187; tutorial</title>
	<atom:link href="http://newsourcemedia.com/blog/tag/tutorial/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Mon, 07 May 2012 01:26:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PHP Lesson 3 &#8211; Creating Functions</title>
		<link>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/</link>
		<comments>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/#comments</comments>
		<pubDate>Mon, 02 May 2005 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[creating functions.]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[lesson]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2005/05/01/php-lesson-3-creating-functions/</guid>
		<description><![CDATA[How to create Functions in PHP and also how to Pass Variables to Functions. Introduction: You will need to have a PHP web server for this tutorial. We recommend SimpleHost.com for only $7.50 with Unlimited Disk Space, Subdomains, and Emails &#8230; <a href="http://newsourcemedia.com/blog/php-lesson-3-creating-functions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to create Functions in PHP and also how to Pass Variables to Functions.
<span id="more-201"></span>
<span class="contitle">Introduction:</span>

You will need to have a PHP web server for this tutorial. We recommend <a href="http://www.simplehost.com/cgi/clickthru.cgi?id=alexmcleaniii">SimpleHost.com</a> for only $7.50 with Unlimited Disk Space, Subdomains, and Emails Accounts.

PHP has hundreds of predefined  functions (maybe thousands). This tutorial gives examples  on how to create your own php functions. There are two rules  I would like to share with you before we start.

<span class="contitle">Rule 1: </span>
Make sure your new function name does not exhist. You can  check PHP.net for a complete list of PHP predefined functions.

<span class="contitle">Rule 2: </span>
Do not declare/define the same function more than once inside the same file. You will get an error.

OK, let's create our first function. This function will display  a text advertisement. We will call this function ads().
<p class="contitle">Source Code</p>

<p class="sourceCODE">&lt;?php
// first define the function
function ads()
{
echo "Visit NewSourceMedia.com for free tutorials";
}
// now call the function ads() like so
ads();
?&gt;

Now you can display the same ad however many times you  want just by calling the function ads().
<p class="contitle">Passing Values to Functions:</p>

Let's say we want to randomly display three ads. We  could do this by placing three text ads inside our ads()  function and then passing a random value to it, to indicate  which ad to display. We can do this by using a parameter  variable inside the function. For example $n will be the  variable and this is how it is placed inside our ads function  like so "ads($n)". This variable holds a copy  of the value passed to it.

Now we need to set $n to a random number between 1 and  3. We can do this by using one of PHP pre-defined functions  called rand(). If you want a random number between 1 and  3 (inclusive), for example, use "rand (1, 3)".  To make this a little more clear, view the code below:
<p class="contitle">Source Code</p>
<p class="sourceCODE">&lt;?php</p>

// first define the function

function ads($n)
{

$a = "http://newsourcemedia.com";

if($n == 1)
echo "&lt;a href='$a'&gt;Visit NewSourceMedia.com for  free tutorials&lt;/a&gt;";

if($n == 2)
echo "&lt;a href='$a'&gt;NewSourceMedia.com for PHP  and much more!&lt;/a&gt;";

if($n == 3)
echo "&lt;a href='$a'&gt;PHP is Number One!&lt;/a&gt;"

} // end of function
<p class="sourceCODE">// define the random value for $n
$n = rand (1, 3);

// now call the function ads() with the value $n
ads($n);

?&gt;]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-lesson-3-creating-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP strip remove white space from end of string</title>
		<link>http://newsourcemedia.com/blog/php-strip-remove-white-space-from-end-of-string/</link>
		<comments>http://newsourcemedia.com/blog/php-strip-remove-white-space-from-end-of-string/#comments</comments>
		<pubDate>Sat, 27 Mar 2004 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[String Manipulation]]></category>
		<category><![CDATA[rtrim]]></category>
		<category><![CDATA[shorten]]></category>
		<category><![CDATA[strip]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[whitespace]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2004/03/26/php-strip-remove-white-space-from-end-of-string/</guid>
		<description><![CDATA[Need to remove the white space at the end of a string before recording the data. Use PHP's rtrim(). rtrim(): rtrim is great for deleting that unwanted space at then end of strings. The perfect example for using this function &#8230; <a href="http://newsourcemedia.com/blog/php-strip-remove-white-space-from-end-of-string/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Need to remove the white space at the end of a string before recording the data. Use PHP's rtrim().
<span id="more-204"></span>
rtrim():

rtrim is great for deleting that unwanted space at then end of strings. The perfect example for using this function is when receiving data from an online form and, at the end of a data field, some one leaves an extra white space. This white space means nothing and you want to delete it. rtrim() to the rescue.

Example:

<pre lang="php">
<?
$password = "123 ";
$password = rtrim($password);
// $password = "123"
?>
</pre>

Other Examples:

You can also trim down a string by matching words or letters and the end of a string.

Example:
<pre lang="php">
// Example 1: Character-by-character comparison match.

echo rtrim('This is a test test code', 'test code');
// returns 'This is a'

// Example 2: matches the last whole word with half the letters

echo rtrim('This is a test', 'est');
// returns 'This is a'
?> 
</pre>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-strip-remove-white-space-from-end-of-string/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Array: Lesson Part 1</title>
		<link>http://newsourcemedia.com/blog/array-lesson-part-1/</link>
		<comments>http://newsourcemedia.com/blog/array-lesson-part-1/#comments</comments>
		<pubDate>Sat, 28 Feb 2004 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Beginner]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[orgaize.]]></category>
		<category><![CDATA[php lesson]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2004/02/27/array-lesson-part-1/</guid>
		<description><![CDATA[Learn PHP arrays and how easy it is to store and organize complex data structures. Introduction: You may already know about PHP variables, and how unfortunately you can only store only one value at a time. But now lets move &#8230; <a href="http://newsourcemedia.com/blog/array-lesson-part-1/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Learn PHP arrays and how easy it is to store and organize complex data structures.
<span id="more-209"></span>
<p class="contitle"><strong>Introduction:</strong></p>

You may already know about PHP variables, and how unfortunately                        you can only store only one value at a time. But now lets move                        on to a new type of variable called an array. Arrays allow                       you to store as many values as you want inside it. It                        keeps track of the information by indexing the data by a                        number or a string. Think of a variable as a bottle of soda.                        And think of an array as a case of sodas, or a warehouse                        of sodas.
<span class="contitle"> <strong>Elements in an Array Example:</strong></span>

<span class="sourceCHART">Values: (“Bart”,                        “Sharon”, “Betty”)
Index Number: (0, 1, 2)
Which Element? (First, Second, Third)</span>

The index always starts as zero. This easy to forget,                        so if you did not get what you expected when outputting                        a value in an array, the chances are that you started counting                        at one instead of zero.

<span class="contitle"><strong>Creating Arrays Use the Array()                        Function:</strong>
</span>
<span class="sourceCODE">$states = array (“NY”,                        “PA”, “CA”)</span>

You can now access the second element by the index “1”:

<span class="sourceCODE">echo “$state”;</span>

This will display as “<span class="sourceHTML">PA</span>”.
<span class="contitle"> <strong>Creating or Adding to Arrays with                        Array Identifier:</strong></span>
<p class="sourceCODE">$states = “NY”;
$states = “PA”;
$states = “CA”;

The values will be listed in the same line order as to                        when they where set. You can also place them in the order                        you want by using the index number placed inside the square                        brackets like so:
<p class="sourceCODE">$states = “PA”;
$states = “CA”;
$states = “NY”;

When using the identifier with an index number to set the                        value, be sure never to set the index number too high. For                        example, if there are only 3 elements in an array and you                        want to add a new value to the end of the array, you must                        use the index number .

The safe way to achieve this would be not to use an index                        number and just leave the square brackets blank like so:
<p class="sourceCODE">$state = array(“NY”, “PA”,                        “CA”);
<span class="sourceCOMMENT">// add a new state to the end                        of the our array of states</span>
$state = “OH”;

<span class="sourceCODE">
</span><strong><span class="contitle">Conclusion:</span></strong>

This is just Part 1 of PHP Array Tutorials for developing                        your on web programs. Be sure to read our Part 2 "Complex                        Data Arrays" to help you master arrays and create more                        dynamic web applications.]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/array-lesson-part-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Source Include</title>
		<link>http://newsourcemedia.com/blog/source-include/</link>
		<comments>http://newsourcemedia.com/blog/source-include/#comments</comments>
		<pubDate>Sat, 28 Feb 2004 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Javascripts]]></category>
		<category><![CDATA[auto include]]></category>
		<category><![CDATA[custom programming]]></category>
		<category><![CDATA[java script]]></category>
		<category><![CDATA[javascript programming]]></category>
		<category><![CDATA[speed]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2004/02/27/source-include/</guid>
		<description><![CDATA[Learn how to save time and money by using the javascript src() function to including local or remote document like headers, footers, css, images, and flash files. Introduction: With Javascript, you can save time and money by using the ("src") &#8230; <a href="http://newsourcemedia.com/blog/source-include/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Learn how to save time and money by using the javascript src() function to including local or remote document like headers, footers, css, images, and flash files.
<span id="more-215"></span>

<span class="contitle">Introduction:</span>

With Javascript, you can save time and money by using the                        ("src") to include remote or local documents.                        For example, you may have a web site serving 20 web pages.                        All 20 pages display the same header and footer item like                        site name, logos and links. However, if you were to change                        the header text, you would have to apply those changes all                        20 pages manualy. That's not fun. Here is a faster way (<a href="../../Tutorials/JS-Include%20Javascript.html" target="_blank">View</a> the test page.)

<span class="contitle">Source Code of included header file (JS-IncludeB.js):</span>

<span class="sourceCODE">&lt;!--
document.writeln('&lt;center&gt;');
document.writeln('&lt;h2&gt;Top: This was included by js&lt;/h2&gt;');
document.writeln('&lt;/center&gt;');
// --&gt;</span>

<span class="contitle">Source Code of included footer file                        (JS-IncludeB.js):</span>

<span class="sourceCODE">&lt;!--
document.writeln('&lt;center&gt;');
document.writeln('&lt;h2&gt;Top: This was included by js&lt;/h2&gt;');
document.writeln('&lt;/center&gt;');
// --&gt;</span>

<span class="contitle">Source Code of main page:</span>

<span class="sourceCODE">&lt;table width="100%" border="0"                        cellpadding="0" cellspacing="0"&gt;
&lt;tr&gt;
&lt;td width="100%" height="42" valign="top"                        bgcolor="#66CCFF"&gt;
&lt;script language="JavaScript" src="JS-IncludeT.js"&gt;
&lt;/script&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" height="49" bgcolor="#FFFFFF"&gt;
&lt;script language="JavaScript" src="JS-IncludeB.js"&gt;
&lt;/script&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td height="175"&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</span>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/source-include/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
