<?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>Scarbous.de &#187; PHP</title>
	<atom:link href="http://www.scarbous.de/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scarbous.de</link>
	<description>Ein weiteres tolles WordPress-Blog</description>
	<lastBuildDate>Fri, 13 May 2011 10:01:50 +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 &#8211; whitespaces aus HTML entfernen und gzip aktivieren</title>
		<link>http://www.scarbous.de/php-whitespaces-aus-html-entfernen-und-gzip-aktivieren/</link>
		<comments>http://www.scarbous.de/php-whitespaces-aus-html-entfernen-und-gzip-aktivieren/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 07:57:22 +0000</pubDate>
		<dc:creator>Sascha</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.scarbous.de/?p=160</guid>
		<description><![CDATA[Suchmaschinen finden es besser wenn eine Internetseite schnell geladen wird, daher ist es gut den ausgegebenen Inhalt zu Komprimieren und alle überflüssigen Zeichen zu entfernen. Das geht sehr einfach mit der Funktion ob_start diese wird ausgeführt bevor der durch PHP generierte Inhalt ausgegeben wird. Ich setze diese Funktion in Verbindung mit WordPress ein: 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>Suchmaschinen finden es besser wenn eine Internetseite schnell geladen wird, daher ist es gut den ausgegebenen Inhalt zu Komprimieren und alle überflüssigen Zeichen zu entfernen.<br />
<span id="more-160"></span><br />
Das geht sehr einfach mit der Funktion <code>ob_start</code> diese wird ausgeführt bevor der durch PHP generierte Inhalt ausgegeben wird.</p>
<p>Ich setze diese Funktion in Verbindung mit WordPress ein:</p>

<div class="wp_codebox"><table><tr id="p1602"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p160code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> make_html<span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$page</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/<span style="color: #000099; font-weight: bold;">\n</span>/&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/\s\s+/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/strpos"><span style="color: #990000;">strpos</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;HTTP_ACCEPT_ENCODING&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gzip&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!==</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<a href="http://www.php.net/header"><span style="color: #990000;">header</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Encoding: gzip&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <a href="http://www.php.net/gzencode"><span style="color: #990000;">gzencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$page</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
	<a href="http://www.php.net/ob_start"><span style="color: #990000;">ob_start</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'make_html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Es werden erst alle whitespaces entfernt und anschließend überprüft ob der Browser gzip unterstützt und dann gegebenen falls Komprimiert was die Seite noch mal um ein vielfaches kleiner macht ( meist über 60%).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarbous.de/php-whitespaces-aus-html-entfernen-und-gzip-aktivieren/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Tags aus einem string lösen</title>
		<link>http://www.scarbous.de/php-tags-aus-einem-string-losen/</link>
		<comments>http://www.scarbous.de/php-tags-aus-einem-string-losen/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 08:01:38 +0000</pubDate>
		<dc:creator>Sascha</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[strip_tags]]></category>
		<category><![CDATA[tag]]></category>

		<guid isPermaLink="false">http://scarbous.de/?p=12</guid>
		<description><![CDATA[Mein erster Anwendungsfall war die NextGen Gallery (ein Plugin für WordPress), bei der ich in Posts automatisch Bilder ausgeben wollte. Dafür fand ich auch eine Funktion, die mir das Bild mit einem link versehen zurück gibt. Durch strip_tags($string, $tag) kann man nun wie in meinem Fall das img tag aus dem string lösen. Beispiel: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>Mein erster Anwendungsfall war die NextGen Gallery (ein Plugin für WordPress), bei der ich in Posts automatisch Bilder ausgeben wollte. Dafür fand ich auch eine Funktion, die mir das Bild mit einem link versehen zurück gibt.<br />
Durch <code>strip_tags($string, $tag)</code> kann man nun wie in meinem Fall das img tag aus dem string lösen.<br />
<span id="more-12"></span><br />
<strong>Beispiel:</strong></p>

<div class="wp_codebox"><table><tr id="p124"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p12code4"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;a title=&quot;“bild“&quot; href=&quot;“bild.jpg“&quot;&gt;&lt;img title=&quot;“Bild“&quot; src=&quot;“bild.jpg“&quot; alt=&quot;“Bild“&quot; /&gt;&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/strip_tags"><span style="color: #990000;">strip_tags</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$string</span><span style="color: #339933;">,</span> „<span style="color: #339933;">&lt;</span>img alt<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">/&gt;</span>“<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$image</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/* ----------
Ausgabe:
&lt;img title=&quot;“Bild“&quot; src=&quot;“bild.jpg“&quot; alt=&quot;“Bild“&quot; /&gt;
---------- */</span></pre></td></tr></table></div>

<p>Nun kann ich das Bild nutzen wie ich möchte.</p>
<p>Weitere Inforamtionen:<br />
<a title="strip-tags bei php.net" href="http://php.net/manual/de/function.strip-tags.php" target="_blank">Funktion: strip-tags</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarbous.de/php-tags-aus-einem-string-losen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

