<?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>php5 &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<atom:link href="https://blog.sephiroth.it/tag/php5/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.sephiroth.it</link>
	<description>programmer by pure chance</description>
	<lastBuildDate>Sun, 20 Jun 2010 09:04:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.sephiroth.it/wp-content/uploads/2019/03/cropped-sepy-big-32x32.png</url>
	<title>php5 &#8211; Alessandro Crugnola &#8211; sephiroth.it</title>
	<link>https://blog.sephiroth.it</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AMFPHP and mbstring</title>
		<link>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/</link>
					<comments>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/#comments</comments>
		
		<dc:creator><![CDATA[Alessandro Crugnola]]></dc:creator>
		<pubDate>Fri, 12 Oct 2007 05:49:02 +0000</pubDate>
				<category><![CDATA[amfphp]]></category>
		<category><![CDATA[amf3]]></category>
		<category><![CDATA[amf3broker]]></category>
		<category><![CDATA[Channel.Ping.Failed]]></category>
		<category><![CDATA[mbstring]]></category>
		<category><![CDATA[php5]]></category>
		<guid isPermaLink="false">http://blog.sephiroth.it/?p=235</guid>

					<description><![CDATA[These days I was working on a flex 2/amfphp project and I discovered a very strange issue accidentally. With PHP 5.2.4 installed both on local and remote server, the local amfphp works and the remote gave errors. Connecting to the service browser I was receiving the error &#8220;Channel.Ping.Failed&#8221; error and investingating a bit more in &#8230; <a href="https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/" class="more-link">Continue reading <span class="screen-reader-text">AMFPHP and mbstring</span></a>]]></description>
										<content:encoded><![CDATA[<p>These days I was working on a flex 2/amfphp project and I discovered a very strange issue accidentally.<br />
With PHP 5.2.4 installed both on local and remote server, the local amfphp works and the remote gave errors.</p>
<p>Connecting to the service browser I was receiving the error &#8220;Channel.Ping.Failed&#8221; error and investingating a bit more in the fault message I discovered that the source error was:</p>
<blockquote><p><em> The class {Amf3Broker} could not be found under the class path {/var/htdocs/amfphp/services/amfphp/Amf3Broker.php} </em></p></blockquote>
<p>and the Amf3Broker php class does not exists anywhere in amfphp! But in the Actions.php file on line 78 I found this:<br />
<code lang="php">if(!$handled)<br />
{<br />
$uriclasspath = "amfphp/Amf3Broker.php";<br />
$classpath = $baseClassPath . "amfphp/Amf3Broker.php";<br />
$classname = "Amf3Broker";<br />
$methodname = "handleMessage";<br />
}</code><br />
That&#8217;s the strange thing because the $handled variable should be true &#8217;cause usually the first request sent by flash is a <strong>$messageType = &#8220;flex.messaging.messages.CommandMessage&#8221;</strong>. So I continued in my investigation logging all the messages that php was receiving.<br />
So at the end I discovered that amfphp didn&#8217;t deserialize the amf data correctly! All the packet were corrupted (that&#8217;s why $messageType wasn&#8217;t handled), all the strings were not correctly parsed.<br />
Finally I discovered the reason. It&#8217;s because <a href="http://it2.php.net/mbstring" target="_blank">mbstring</a>.<br />
The only difference between the remote server and the local server is the php.ini setting about mbstring <a href="http://it2.php.net/manual/en/ref.mbstring.php#mbstring.overload" target="_blank">overload</a> and the others mbstring settings.<br />
The remote server has mbstring.func_overload = 2, that means all the strings functions are affected and that&#8217;s why the amfphp methods were returing corrupted data.<br />
In fact I just changed this method into AMFDeserializer.php:<br />
<code lang="php">function readBuffer($len)<br />
{<br />
$data = substr($this->raw_data,$this->current_byte,$len);<br />
$this->current_byte += $len;<br />
return $data;<br />
}</code><br />
into:<br />
<code lang="php">function readBuffer($len)<br />
{<br />
$data = "";<br />
for($i = 0; $i < $len; $i++)
{
$data .= $this->raw_data{$i + $this->current_byte};<br />
}<br />
$this->current_byte += $len;<br />
return $data;<br />
}</code><br />
and the original error disappeared! Obviously I got other errors later, that&#8217;s because there are many other string functions in amfphp.. but at least I found the cause.</p>
<p>In fact, removing the mbstring.func_overload in the php.ini everything worked again!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.sephiroth.it/2007/10/11/amfphp-and-mbstring/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
