<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-12844422</id><updated>2011-07-22T05:19:43.622-07:00</updated><title type='text'>PHP Tricks &amp; Tips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phptricks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phptricks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Dustin Davis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_Vq_gDnQmZgg/TEQqCQG1a4I/AAAAAAAACCU/Pr4DcCzbu9k/S220/me.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>3</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-12844422.post-112496880471129512</id><published>2005-08-25T04:20:00.000-07:00</published><updated>2005-08-25T04:21:54.746-07:00</updated><title type='text'>PHP Script to variable</title><content type='html'>The following I found on a Usenet post on how to EASILY parse a PHP script’s output to a variable using output buffering:&lt;br/&gt;&lt;br/&gt;"Daniel Loose" &amp;lt;nore&lt;a href="http://groups.google.com/groups/unlock?msg=ec0cdb86d983df34&amp;_done=/group/comp.lang.php/browse_frm/thread/4937e97657dcfab1%3F"&gt;...&lt;/a&gt;@web.de&amp;gt; kirjoitti viestissä:430cb793.9399&lt;a href="http://groups.google.com/groups/unlock?msg=ec0cdb86d983df34&amp;_done=/group/comp.lang.php/browse_frm/thread/4937e97657dcfab1%3F"&gt;...&lt;/a&gt;@news.cs.tu-berlin.de... &lt;br/&gt;&amp;gt; Hello, &lt;br/&gt;&amp;gt; I have this strange including problem: &lt;br/&gt;&amp;gt; I want to read a piece of HTML, residing in some file, into a &amp;gt; variable, not echo it out. So far so easy - but now the HTML contains &amp;gt; a line of PHP. And I wish not to get the PHP code into my variable but &amp;gt; the parsed result, just like if the variable was a client ;-). I wish &amp;gt; to keep the nice ?&amp;gt; ...&amp;lt;? HTML area (with highlighting in my editor), &amp;gt; and therefore include etc. don't help because they would echo it out. &amp;gt; heredoc also doesnt help (if this may come up to your mind). &lt;br/&gt;&amp;gt; Is there anything I can do...?!! The problem sounds so simple... the &amp;gt; more for such a great tool like PHP ... but... ?!! &lt;br/&gt;&lt;br/&gt;Sounds like you could use buffering. &lt;br /&gt;&lt;br /&gt;&lt;?php &lt;br /&gt;ob_start(); // Start output buffering. &lt;br /&gt;// Instead of outputting anything, the output is now stored in a buffer. &lt;br /&gt;include('yourfile.php'); &lt;br /&gt;// There, now the file has been included and php parsed. &lt;br /&gt;// It isn't output, it goes into the buffer. &lt;br /&gt;$yourfile = ob_get_clean(); &lt;br /&gt;// Now we read everything that has been buffered... And stops buffering. &lt;br /&gt;?&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;Result: the file you included has been parsed by the php engine and stored inside $yourfil, and nothing was output. Sounds like goal achieved. &lt;br/&gt;-- SETI @ Home - Donate your cpu's idle time to science. Further reading at &amp;lt;&lt;a href="http://setiweb.ssl.berkeley.edu/"&gt;http://setiweb.ssl.berkeley.ed u/&lt;/a&gt;&amp;gt; Kimmo Laine &amp;lt;eternal.erectio&lt;a href="http://groups.google.com/groups/unlock?msg=ec0cdb86d983df34&amp;_done=/group/comp.lang.php/browse_frm/thread/4937e97657dcfab1%3F"&gt;...&lt;/a&gt;@5P4Mgmail.com&amp;gt; &lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12844422-112496880471129512?l=phptricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phptricks.blogspot.com/feeds/112496880471129512/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12844422&amp;postID=112496880471129512' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/112496880471129512'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/112496880471129512'/><link rel='alternate' type='text/html' href='http://phptricks.blogspot.com/2005/08/php-script-to-variable.html' title='PHP Script to variable'/><author><name>Dustin Davis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_Vq_gDnQmZgg/TEQqCQG1a4I/AAAAAAAACCU/Pr4DcCzbu9k/S220/me.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12844422.post-111590886785496528</id><published>2005-05-12T07:22:00.000-07:00</published><updated>2005-05-12T07:41:07.863-07:00</updated><title type='text'>Page templates</title><content type='html'>Many of you may have heard of SMARTY. I've used it once. I just think it makes &lt;br /&gt;the hard things easy and the easy things hard. I suppose it is useful if you are &lt;br /&gt;in a multi-programmer environment, but I would rather just use run of the mill &lt;br /&gt;PHP rather than incorporating smarty templates.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Here is basically how I create every new website I do. I start by creating a &lt;br /&gt;basic layout - or I could even purchase a cheap one from&lt;br /&gt;&lt;a href="http://basictemplates.com/"&gt;basictemplates.com&lt;/a&gt; where all templates &lt;br /&gt;are only $5. I also have a bunch on disk. I normally use these for ideas and &lt;br /&gt;create a new one from scratch. I often use FrontPage 2003 and Adobe Photoshop to &lt;br /&gt;help create the main template page, then I clean it up using&lt;br /&gt;&lt;a href="http://www.textpad.com/"&gt;TextPad &lt;/a&gt;- my favorite text editor.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;After determining where all the main content will be I will break the page apart &lt;br /&gt;at that point into headers and footers.&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Here is a basic example of what my header file will look like:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;code&gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br&gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br&gt;&lt;br /&gt;&amp;lt;title&amp;gt;&amp;lt;?=$ptitle?&amp;gt;&amp;lt;/title&amp;gt;&lt;br&gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br&gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;My footer could be simply as follows:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;code&gt;&amp;lt;/body&amp;gt;&lt;br&gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Then, to create a new page, I would use the following template for each new &lt;br /&gt;page:&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;code&gt;&amp;lt;?&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $ptitle = 'Page Title';&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; require 'header.php';&lt;br&gt;&lt;br /&gt;?&amp;gt;&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;Content goes here...&lt;br&gt;&lt;br /&gt;&lt;br&gt;&lt;br /&gt;&amp;lt;?&lt;br&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; require 'footer.php';&lt;br&gt;&lt;br /&gt;?&amp;gt;&lt;/code&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;That, in essence is simply all there is to it. You can make your header and &lt;br /&gt;footer file as elaborate as you need to. Some things you may notice here are:&lt;/p&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt; &lt;li&gt;I set the &lt;code&gt;$ptitle&lt;/code&gt; variable in my page file. It is inserted &lt;br /&gt; in the template between the title tags.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;I use the &lt;code&gt;require&lt;/code&gt; function to include the header and footer &lt;br /&gt;files. You could also use &lt;code&gt;include()&lt;/code&gt;, &lt;code&gt;include_once()&lt;/code&gt;, or &lt;code&gt;&lt;br /&gt;require_once()&lt;/code&gt;. See &lt;a href="http://www.php.net"&gt;php.net&lt;/a&gt; for the &lt;br /&gt;differences of these functions.&lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12844422-111590886785496528?l=phptricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phptricks.blogspot.com/feeds/111590886785496528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12844422&amp;postID=111590886785496528' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/111590886785496528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/111590886785496528'/><link rel='alternate' type='text/html' href='http://phptricks.blogspot.com/2005/05/page-templates.html' title='Page templates'/><author><name>Dustin Davis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_Vq_gDnQmZgg/TEQqCQG1a4I/AAAAAAAACCU/Pr4DcCzbu9k/S220/me.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-12844422.post-111590769744775988</id><published>2005-05-12T07:18:00.000-07:00</published><updated>2005-05-12T07:21:37.450-07:00</updated><title type='text'>Welcome</title><content type='html'>Welcome to PHP Tricks! I do a lot of PHP Programming. I just thought it would be fun to share some some tricks &amp;amp; tips I pick up in my day to day programming. Then, I can get feedback and maybe more ideas from readers and fellow blogsters!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/12844422-111590769744775988?l=phptricks.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phptricks.blogspot.com/feeds/111590769744775988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=12844422&amp;postID=111590769744775988' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/111590769744775988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/12844422/posts/default/111590769744775988'/><link rel='alternate' type='text/html' href='http://phptricks.blogspot.com/2005/05/welcome.html' title='Welcome'/><author><name>Dustin Davis</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://1.bp.blogspot.com/_Vq_gDnQmZgg/TEQqCQG1a4I/AAAAAAAACCU/Pr4DcCzbu9k/S220/me.jpg'/></author><thr:total>0</thr:total></entry></feed>
