<?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>Coding Friends</title>
	<atom:link href="http://www.codingfriends.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingfriends.com</link>
	<description>Coding Friends, place for developers.</description>
	<lastBuildDate>Sat, 08 Dec 2012 13:37:26 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>PHP &#8211; function use</title>
		<link>http://www.codingfriends.com/index.php/2012/12/08/php-function-use/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-function-use</link>
		<comments>http://www.codingfriends.com/index.php/2012/12/08/php-function-use/#comments</comments>
		<pubDate>Sat, 08 Dec 2012 13:37:26 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1792</guid>
		<description><![CDATA[As with the previous post about the use method within php (here), you are also able to use the use method attached to a callable function as in function &#40;$parameter&#41; USE &#40;$somevalue&#41; So you are able to use any variables that are within scope within the new function, below is an example where I am [...]]]></description>
				<content:encoded><![CDATA[<p>As with the previous post about the use method within php (<a href="http://www.codingfriends.com/index.php/2012/07/11/php-use/" title="here">here</a>), you are also able to use the use method attached to a callable function as in</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameter</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">USE</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$somevalue</span><span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>So you are able to use any variables that are within scope within the new function, below is an example where I am using the <a href="http://uk1.php.net/array_walk" title="array walk">array walk</a> methods callback (which means call a function that is available).  The function is using the values within the array ($arrays 4 and 5) and adding them to the $value variable that is passed within the use parameters (here I am using the &#038; symbol which means to pass in reference and not just a copy of the value (you are able to alter the actual parameter passed), so in this instance the $value starts of with 1, then adds 4 and then 5 to it which in turn the result is 10.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$callback</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$one</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">use</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$value</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$one</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$arrays</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">4</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">array_walk</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrays</span><span style="color: #339933;">,</span> <span style="color: #000088;">$callback</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;value : &quot;</span> <span style="color: #339933;">.</span><span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And the output would be.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">value : <span style="color: #000000;">10</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2012/12/08/php-function-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WFC Soap class within an class communicating with PHP</title>
		<link>http://www.codingfriends.com/index.php/2012/08/04/wfc-soap-class-within-an-class-communicating-with-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wfc-soap-class-within-an-class-communicating-with-php</link>
		<comments>http://www.codingfriends.com/index.php/2012/08/04/wfc-soap-class-within-an-class-communicating-with-php/#comments</comments>
		<pubDate>Sat, 04 Aug 2012 21:00:20 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[C Sharp (c#)]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[SOAP]]></category>
		<category><![CDATA[WFC]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1783</guid>
		<description><![CDATA[Within the Windows Foundation Classes you are able to create SOAP end points. These end points you are able to communicate using classes funny enough (because of the WFC being classes). But to communicate with these is fine with PHP and also when you sometimes have a class within an class as a parameter passing [...]]]></description>
				<content:encoded><![CDATA[<p><span id="zipfile"><a href='http://www.codingfriends.com/wp-content/uploads/2012/08/WFC.SOAP_PHP.zip'></a></span>Within the <a href="http://en.wikipedia.org/wiki/Microsoft_Foundation_Class_Library" title="Windows Foundation Class" target="_blank">Windows Foundation Classes</a> you are able to create SOAP end points.  These end points you are able to communicate using classes funny enough (because of the WFC being classes).  But to communicate with these is fine with PHP and also when you sometimes have a class within an class as a parameter passing to the SOAP end point.  Well you are able to do it within PHP as well.</p>
<p>If you have a WFC service and add these to the service for the ServiceContract and create the DataContract&#8217;s and DataMembers</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #008000;">&#91;</span>ServiceContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IService1
<span style="color: #008000;">&#123;</span>
    <span style="color: #008000;">&#91;</span>OperationContract<span style="color: #008000;">&#93;</span>
    <span style="color: #6666cc; font-weight: bold;">string</span> NewValue<span style="color: #008000;">&#40;</span>NewName name<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>DataContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SecondName
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> svalue1<span style="color: #008000;">;</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> svalue2<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>DataMember<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Svalue1
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">get</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> svalue1<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">set</span> <span style="color: #008000;">&#123;</span> svalue1 <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">value</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>DataMember<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Svalue2
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">get</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> svalue2<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">set</span> <span style="color: #008000;">&#123;</span> svalue2 <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">value</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
&nbsp;
<span style="color: #008000;">&#91;</span>DataContract<span style="color: #008000;">&#93;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> NewName
<span style="color: #008000;">&#123;</span>
    SecondName secondValue <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> SecondName<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #008000;">&#91;</span>DataMember<span style="color: #008000;">&#93;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> SecondName SecondValue
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">get</span> <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> secondValue<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">set</span> <span style="color: #008000;">&#123;</span> secondValue <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">value</span><span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Created the SecondName class as the second named class with the svalue1/2 within in turn the NewName named class will reference the SecondName class.</p>
<p>And then within the class that implements the interface here is the function name to call within the soap end point called NewValue.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">string</span> NewValue<span style="color: #008000;">&#40;</span>NewName namesec<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Format</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Value : {0}&quot;</span>, namesec<span style="color: #008000;">.</span><span style="color: #0000FF;">SecondValue</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Svalue1</span> <span style="color: #008000;">+</span> namesec<span style="color: #008000;">.</span><span style="color: #0000FF;">SecondValue</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Svalue2</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>Well to find out what you need to pass to the soap call I was using an WFC application to write out the debugging information with altering the web.config by</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;">    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.serviceModel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;diagnostics<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;messageLogging</span></span>
<span style="color: #009900;">             <span style="color: #000066;">logEntireMessage</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">logMalformedMessages</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">logMessagesAtServiceLevel</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">logMessagesAtTransportLevel</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">maxMessagesToLog</span>=<span style="color: #ff0000;">&quot;3000&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">maxSizeOfMessageToLog</span>=<span style="color: #ff0000;">&quot;2000&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/diagnostics<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.serviceModel<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system.diagnostics<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;System.ServiceModel.MessageLogging&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listeners<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;add</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;messages&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;System.Diagnostics.XmlWriterTraceListener&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">initializeData</span>=<span style="color: #ff0000;">&quot;c:\temp\messages.svclog&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listeners<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sources<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system.diagnostics<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>which in turns creates a file and in that file there is xml definition what is being sent.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;NewValue</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://tempuri.org/&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name</span> <span style="color: #000066;">xmlns:d4p1</span>=<span style="color: #ff0000;">&quot;http://schemas.datacontract.org/2004/07/WcfService1&quot;</span> <span style="color: #000066;">xmlns:i</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;d4p1:SecondValue<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;d4p1:Svalue1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>200<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/d4p1:Svalue1<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;d4p1:Svalue2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>100<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/d4p1:Svalue2<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/d4p1:SecondValue<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/NewValue<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/s:Body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xml<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>and within PHP you are able to copy this. but note that the parameter to send is &#8220;name&#8221; which is not the same as the parameter above (namesec) you have to send to &#8220;name&#8221; which is what the soap end point is looking for.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> SecondName <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$Svalue1</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$Svalue2</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> NewName <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000088;">$SecondValue</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> NewName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$s1</span><span style="color: #339933;">,</span> <span style="color: #000088;">$s2</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SecondValue</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SecondName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SecondValue</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Svalue1</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$s1</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SecondValue</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Svalue2</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$s2</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$objN</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> NewName<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">200</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Create a SOAP client</span>
<span style="color: #000088;">$client</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SoapClient<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://192.168.0.3/Service1.svc?wsdl&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$retVal</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">NewValue</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objN</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$retVal</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">NewValueResult</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>and the output is</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">Value : <span style="color: #000000;">300</span></pre></td></tr></table></div>

<p>Have attached a file of the project for the WFC webserver and also the php code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2012/08/04/wfc-soap-class-within-an-class-communicating-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Use</title>
		<link>http://www.codingfriends.com/index.php/2012/07/11/php-use/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-use</link>
		<comments>http://www.codingfriends.com/index.php/2012/07/11/php-use/#comments</comments>
		<pubDate>Wed, 11 Jul 2012 19:20:27 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[use]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1780</guid>
		<description><![CDATA[php use]]></description>
				<content:encoded><![CDATA[<p>From a follow on from my previous post about <a href="http://www.codingfriends.com/index.php/2012/07/10/php-namespace/" title="namespace">namespace</a>, when you want to use another name, shorter than the actual namespace of the namespace you are able to use &#8220;use&#8221;.  Probably best to show in code</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;codingfriends.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> codingfriends <span style="color: #b1b100;">as</span> cf<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> cf\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>the codingfriends.php file is</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">namespace</span> codingfriends<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Say hello from codingfriends.&quot;</span><span style="color: #339933;">;</span>    
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sayHelloFromSub<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> sub\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>so that the &#8220;use&#8221; will alter the namespace of codingfriends to cf instead so that you are able to call codingfriends as cf, so when</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> cf\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>is called it will call the codingfriends\sayHello() function.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2012/07/11/php-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; namespace</title>
		<link>http://www.codingfriends.com/index.php/2012/07/10/php-namespace/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=php-namespace</link>
		<comments>http://www.codingfriends.com/index.php/2012/07/10/php-namespace/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 19:33:10 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[namespace]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1776</guid>
		<description><![CDATA[PHP - namespace.]]></description>
				<content:encoded><![CDATA[<p><a title="Namespace" href="http://www.php.net/manual/en/language.namespaces.rationale.php" target="_blank">Namespace</a>&#8216;ing is a great way of splitting functions / classes into different spaces that could have the same name but do not cause issues.  This is great if you are trying to combine different projects together that many have the same function names and you want to call different projects code functions without having to worry that you are calling the wrong function.</p>
<p>For example if you have a file called codingfriends.php</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">namespace</span> codingfriends<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Say hello from codingfriends.&quot;</span><span style="color: #339933;">;</span>    
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sayHelloFromSub<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> sub\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>and another file called codingfriendssub.php</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">namespace</span> codingfriends\sub<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Say hello from codingfriends sub module&quot;</span><span style="color: #339933;">;</span>    
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>and then have the index.php file</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;codingfriends.php&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">include</span> <span style="color: #0000ff;">&quot;codingfriends.sub.php&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> codingfriends\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// calling the codingfriends namespace</span>
<span style="color: #b1b100;">echo</span> codingfriends\sub\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// call the codingfriends sub namespace</span>
<span style="color: #b1b100;">echo</span> codingfriends\sayHelloFromSub<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// calling the sub namespace quicker.</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>then the first two lines include the two different name spaces and you are able to call the same function names without having to worry that you are calling the wrong function.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> codingfriends\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// calling the codingfriends namespace</span></pre></td></tr></table></div>

<p>will call the sayHello() from within the namespace codingfriends</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> codingfriends\sub\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br/&gt;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// call the codingfriends sub namespace</span></pre></td></tr></table></div>

<p>will call the namespace codingfriendssub sayHello function and the best thing is is if you are within a namespace and want to call a sub namespace within your namespace (it is like a tree with roots) you are able to do</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #b1b100;">echo</span> sub\sayHello<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>from within the namespace codingfriends, it will find the codingfriends\sub namespace and then call the sayHello() function within that namespace.</p>
<p>The output would be for the index.php file</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">Say hello from codingfriends.
Say hello from codingfriends sub module
Say hello from codingfriends sub module</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2012/07/10/php-namespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Good courses</title>
		<link>http://www.codingfriends.com/index.php/2012/07/10/good-courses/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=good-courses</link>
		<comments>http://www.codingfriends.com/index.php/2012/07/10/good-courses/#comments</comments>
		<pubDate>Tue, 10 Jul 2012 19:02:58 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[online courses]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1774</guid>
		<description><![CDATA[courses that are good for oline]]></description>
				<content:encoded><![CDATA[<p>After some looking around, I have found some really good courses that show good coding standards and also allowed to be viewed online even if you are not paying.</p>
<p><a title="David Malan" href="http://www.cs.harvard.edu/malan/" target="_blank">David J. Malan</a>, is a very good instructor and one of his courses</p>
]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2012/07/10/good-courses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google python code, string2.py</title>
		<link>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-python-code-string2-py</link>
		<comments>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 21:11:08 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[google code]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1764</guid>
		<description><![CDATA[As from the previous post, I am doing the google&#8217;s python class code and if any one comes up different solutions to the googles version or mine, please post. So here is the string2.py solutions from me. Verbing, needs to check for string over 3 and then only compare the last 3 characters for &#8216;ing&#8217; [...]]]></description>
				<content:encoded><![CDATA[<p>As from the <a href="http://www.codingfriends.com/index.php/2011/12/04/google-python-code/">previous post</a>, I am doing the google&#8217;s python class code and if any one comes up different solutions to the googles version or mine, please post.  So here is the string2.py solutions from me.</p>
<p>Verbing, needs to check for string over 3 and then only compare the last 3 characters for &#8216;ing&#8217;</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># D. verbing</span>
<span style="color: #808080; font-style: italic;"># Given a string, if its length is at least 3,</span>
<span style="color: #808080; font-style: italic;"># add 'ing' to its end.</span>
<span style="color: #808080; font-style: italic;"># Unless it already ends in 'ing', in which case</span>
<span style="color: #808080; font-style: italic;"># add 'ly' instead.</span>
<span style="color: #808080; font-style: italic;"># If the string length is less than 3, leave it unchanged.</span>
<span style="color: #808080; font-style: italic;"># Return the resulting string.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> verbing<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">3</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s
  <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: black;">&#40;</span>s<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">3</span>:<span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span><span style="color: #483d8b;">'ing'</span><span style="color: black;">&#41;</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s + <span style="color: #483d8b;">'ly'</span>
  <span style="color: #ff7700;font-weight:bold;">else</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s + <span style="color: #483d8b;">'ing'</span></pre></td></tr></table></div>

<p>Not bad, find the &#8216;not&#8217; and &#8216;bad&#8217;, if bad after not then replace.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># E. not_bad</span>
<span style="color: #808080; font-style: italic;"># Given a string, find the first appearance of the</span>
<span style="color: #808080; font-style: italic;"># substring 'not' and 'bad'. If the 'bad' follows</span>
<span style="color: #808080; font-style: italic;"># the 'not', replace the whole 'not'...'bad' substring</span>
<span style="color: #808080; font-style: italic;"># with 'good'.</span>
<span style="color: #808080; font-style: italic;"># Return the resulting string.</span>
<span style="color: #808080; font-style: italic;"># So 'This dinner is not that bad!' yields:</span>
<span style="color: #808080; font-style: italic;"># This dinner is good!</span>
<span style="color: #ff7700;font-weight:bold;">def</span> not_bad<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  notV <span style="color: #66cc66;">=</span> s.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'not'</span><span style="color: black;">&#41;</span>
  badV <span style="color: #66cc66;">=</span> s.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'bad'</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>badV <span style="color: #66cc66;">&gt;</span> notV<span style="color: black;">&#41;</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span>:notV<span style="color: black;">&#93;</span> + <span style="color: #483d8b;">'good'</span> + s<span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>badV+<span style="color: #ff4500;">3</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s</pre></td></tr></table></div>

<p>Font back, here we needed the modulus function to find out the reminder of a division.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># F. front_back</span>
<span style="color: #808080; font-style: italic;"># Consider dividing a string into two halves.</span>
<span style="color: #808080; font-style: italic;"># If the length is even, the front and back halves are the same length.</span>
<span style="color: #808080; font-style: italic;"># If the length is odd, we'll say that the extra char goes in the front half.</span>
<span style="color: #808080; font-style: italic;"># e.g. 'abcde', the front half is 'abc', the back half 'de'.</span>
<span style="color: #808080; font-style: italic;"># Given 2 strings, a and b, return a string of the form</span>
<span style="color: #808080; font-style: italic;">#  a-front + b-front + a-back + b-back</span>
<span style="color: #ff7700;font-weight:bold;">def</span> front_back<span style="color: black;">&#40;</span>a<span style="color: #66cc66;">,</span> b<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  aV <span style="color: #66cc66;">=</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>+<span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>a<span style="color: black;">&#41;</span>%<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
  bV <span style="color: #66cc66;">=</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>b<span style="color: black;">&#41;</span>/<span style="color: #ff4500;">2</span>+<span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>b<span style="color: black;">&#41;</span>%<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> a<span style="color: black;">&#91;</span>:aV<span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span>:bV<span style="color: black;">&#93;</span>+a<span style="color: black;">&#91;</span>aV:<span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span>bV:<span style="color: black;">&#93;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/12/04/google-python-code-string2-py/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google python code</title>
		<link>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-python-code</link>
		<comments>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/#comments</comments>
		<pubDate>Sun, 04 Dec 2011 21:04:00 +0000</pubDate>
		<dc:creator>genux</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[google code]]></category>

		<guid isPermaLink="false">http://www.codingfriends.com/?p=1762</guid>
		<description><![CDATA[After been talking with some friends, they said about putting some of the google code from there classes online encase other people come up with any other versions. So from the first of the classes that they was talking about was Python , so here is my code for these, may be other people may [...]]]></description>
				<content:encoded><![CDATA[<p>After been talking with some friends, they said about putting some of the <a href="http://code.google.com/edu/">google code</a> from there classes online encase other people come up with any other versions.  So from the first of the classes that they was talking about was <a href="http://code.google.com/edu/languages/google-python-class/">Python </a>, so here is my code for these, may be other people may be doing and come up with different code ?</p>
<p>For first string1.py test there is 4 functions that you have code up and in order from the source code.</p>
<p>Donut, as from the below you just need do a compare on the parameter in.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># A. donuts</span>
<span style="color: #808080; font-style: italic;"># Given an int count of a number of donuts, return a string</span>
<span style="color: #808080; font-style: italic;"># of the form 'Number of donuts: &lt;count&gt;', where &lt;count&gt; is the number</span>
<span style="color: #808080; font-style: italic;"># passed in. However, if the count is 10 or more, then use the word 'many'</span>
<span style="color: #808080; font-style: italic;"># instead of the actual count.</span>
<span style="color: #808080; font-style: italic;"># So donuts(5) returns 'Number of donuts: 5'</span>
<span style="color: #808080; font-style: italic;"># and donuts(23) returns 'Number of donuts: many'</span>
<span style="color: #ff7700;font-weight:bold;">def</span> donuts<span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> count <span style="color: #66cc66;">&gt;=</span> <span style="color: #ff4500;">10</span>:
     <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'Number of donuts: many'</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">'Number of donuts: '</span> + <span style="color: #008000;">str</span><span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Both end, it is string manipulation and returning part of the string if longer enough.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># B. both_ends</span>
<span style="color: #808080; font-style: italic;"># Given a string s, return a string made of the first 2</span>
<span style="color: #808080; font-style: italic;"># and the last 2 chars of the original string,</span>
<span style="color: #808080; font-style: italic;"># so 'spring' yields 'spng'. However, if the string length</span>
<span style="color: #808080; font-style: italic;"># is less than 2, return instead the empty string.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> both_ends<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #ff4500;">2</span>:
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">''</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> + s<span style="color: black;">&#91;</span>-<span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span></pre></td></tr></table></div>

<p>Fix start, replace the characters within the string with a * that the same as the first character, so just need to concatenate the first character with the rest of the characters with any replaced <img src='http://www.codingfriends.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># C. fix_start</span>
<span style="color: #808080; font-style: italic;"># Given a string s, return a string</span>
<span style="color: #808080; font-style: italic;"># where all occurences of its first char have</span>
<span style="color: #808080; font-style: italic;"># been changed to '*', except do not change</span>
<span style="color: #808080; font-style: italic;"># the first char itself.</span>
<span style="color: #808080; font-style: italic;"># e.g. 'babble' yields 'ba**le'</span>
<span style="color: #808080; font-style: italic;"># Assume that the string is length 1 or more.</span>
<span style="color: #808080; font-style: italic;"># Hint: s.replace(stra, strb) returns a version of string s</span>
<span style="color: #808080; font-style: italic;"># where all instances of stra have been replaced by strb.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> fix_start<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> s<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + s<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:<span style="color: black;">&#93;</span>.<span style="color: black;">replace</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span><span style="color: #483d8b;">'*'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Mix up, change the first 2 characters from the two parameters around.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># D. MixUp</span>
<span style="color: #808080; font-style: italic;"># Given strings a and b, return a single string with a and b separated</span>
<span style="color: #808080; font-style: italic;"># by a space '&lt;a&gt; &lt;b&gt;', except swap the first 2 chars of each string.</span>
<span style="color: #808080; font-style: italic;"># e.g.</span>
<span style="color: #808080; font-style: italic;">#   'mix', pod' -&gt; 'pox mid'</span>
<span style="color: #808080; font-style: italic;">#   'dog', 'dinner' -&gt; 'dig donner'</span>
<span style="color: #808080; font-style: italic;"># Assume a and b are length 2 or more.</span>
<span style="color: #ff7700;font-weight:bold;">def</span> mix_up<span style="color: black;">&#40;</span>a<span style="color: #66cc66;">,</span> b<span style="color: black;">&#41;</span>:
  <span style="color: #808080; font-style: italic;"># +++your code here+++</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> b<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>+a<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span>+<span style="color: #483d8b;">' '</span>+a<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>+b<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.codingfriends.com/index.php/2011/12/04/google-python-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
