<?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>Gadratil Programming &#187; Gadratil</title>
	<atom:link href="http://www.gadratilprogramming.net/author/gadratil/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gadratilprogramming.net</link>
	<description>Re-imagine the small things</description>
	<lastBuildDate>Fri, 13 Mar 2026 16:50:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.2.38</generator>
	<item>
		<title>Try Blogging!</title>
		<link>http://www.gadratilprogramming.net/try-blogging/</link>
		<comments>http://www.gadratilprogramming.net/try-blogging/#comments</comments>
		<pubDate>Wed, 27 Jan 2021 11:39:52 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=385</guid>
		<description><![CDATA[If you want to have a blog (free), you can try WordPress! I use WordPress for both developing websites in it, but also for hosting my blogs. If you want to check it out, just click: https://wordpress.com/refer-a-friend/Qp724w3hVxKKzmBG6xgj/]]></description>
				<content:encoded><![CDATA[<p>If you want to have a blog (free), you can try WordPress!</p>
<p>I use WordPress for both developing websites in it, but also for hosting my blogs.</p>
<p>If you want to check it out, just click:</p>
<p><a href="https://wordpress.com/refer-a-friend/Qp724w3hVxKKzmBG6xgj/">https://wordpress.com/refer-a-friend/Qp724w3hVxKKzmBG6xgj/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/try-blogging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Page view generator</title>
		<link>http://www.gadratilprogramming.net/page-view-generator/</link>
		<comments>http://www.gadratilprogramming.net/page-view-generator/#comments</comments>
		<pubDate>Mon, 13 Jul 2020 06:55:23 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[page view generator]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[random]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=377</guid>
		<description><![CDATA[As I have a website, I started to check out google ads and how they work. I was also curious if there was a way to generate views on a page. So this curiosity led me to write my own page view generator. First of all, I needed a way to simulate real life user [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>As I have a website, I started to check out google ads and how they work. I was also curious if there was a way to generate views on a page. So this curiosity led me to write my own page view generator.</p>
<p>First of all, I needed a way to simulate real life user interaction with a website. For this, you need a browser. My first choice was <a href="https://phantomjs.org/" target="_blank">PhantomJs </a>but it turned out to be difficult to work with. After a lot of research, I finally stayed with headless chrome.</p>
<p>So now, that I had a browser, I needed to simulate user interaction. Also, I wanted the views to be from different parts of the world, not just from one IP address, so for that I needed to somehow use proxy&#8217;s. I found a way to either use a proxy from a file, or always load the latest proxy list from an online source.</p>
<p>https://raw.githubusercontent.com/clarketm/proxy-list/master/proxy-list.txt</p>
<p>After I had the proxy&#8217;s, I needed the interaction to seem random, so I randomized the browser headers, the links the bot followed and the length of time it stayed on a page.</p>
<p>Finally I had a running script that could generate 200+ views.</p>
<p>My first page view generator was ready and tested. You can find technical information in the README of the project.</p>
<p>Here is the code for those who are eager to give it a try:</p>
<p><a href="https://gitlab.com/Gadratil/pvg" target="_blank">https://gitlab.com/Gadratil/pvg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/page-view-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Data security and accessibility by moving to the Cloud</title>
		<link>http://www.gadratilprogramming.net/data-security-and-accessibility-by-moving-to-the-cloud/</link>
		<comments>http://www.gadratilprogramming.net/data-security-and-accessibility-by-moving-to-the-cloud/#comments</comments>
		<pubDate>Fri, 07 Jul 2017 12:09:51 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[google drive]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[one drive]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[web interface]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=300</guid>
		<description><![CDATA[We live in a beautiful era. Almost everyone now has Internet, so we are always connected with each other and our things online. It is an increasing trend to create applications that run on the internet, instead of running on the client device. Also, there are applications that come from the server, but do the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>We live in a beautiful era. Almost everyone now has Internet, so we are always connected with each other and our things online.</p>
<p>It is an increasing trend to create applications that run on the internet, instead of running on the client device. Also, there are applications that come from the server, but do the heavy load on the client side. Web interfaces are very common and you need to download less and less applications.</p>
<p>So, in this era, why would someone move to the cloud?</p>
<h3>What moving to the cloud means</h3>
<p>Moving to the cloud means keeping your data on servers and not on your own device. The best example probably is keeping your photos online. This has many forms, for example you make a lot of pictures for your social sites, they are kept in the &#8220;cloud&#8221;, meaning on the servers of the given social site. There are file syncing applications also, like Google Drive or One Drive that keep a copy of the shared files in the cloud, so no matter what happens to your device, your files are safe. This started to be a bigger and bigger trend and it is good, because it shifts us from being so dependent of our devices.</p>
<p>In a near future I can imagine a case when our devices have only one functionality: accessing the internet. Our everything would be online, in the cloud, so the device just has to grant us access.</p>
<h3>A simple example of using the cloud</h3>
<p>I personally use the cloud to store data that I do not want to lose. I store my credentials for example in the cloud, scattered in many places. In this way I do not have to remember all my passwords (I have soooo many!), I just have to remember where I scattered the data. Also, I keep important files also in the cloud, like scripts written by me, documentations, important personal documents.</p>
<p>Personal documents are a good example, because if you need any of them, you just download them on your phone and print them. This kind of accessibility saves you a lot of time.</p>
<h3>Concerns about cloud safety</h3>
<p>Many fear to share their data with the cloud, to keep their personal things online. They say that these technologies are not safe enough, that their personal files could leak out.</p>
<p>The thing is, that your device is probably more vulnerable on a network than a Google server. So leaking data from your personal device is more likely than from a Google server.</p>
<p>Of course, you have the right to keep your data where you want it. When data gets lost, it gets lost. It can be a piece of paper, too, if you lose it, the data on it is lost. So, keeping multiple copy&#8217;s is always a good practice, no matter where you keep your data.</p>
<p>I usually have nothing to hide, so I am not afraid to keep data in the cloud. The intellectual property I have can be stolen, of course, but I have the knowledge to recreate it, and the one who stole it does not necessarily understand it.</p>
<h3>Conclusion</h3>
<p>Nowadays the Cloud is a safe place to keep your things in. Just trust the big providers, they know what to do. Moving to the cloud enables you to become device independent and that is a pretty big freedom if you ask me.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/data-security-and-accessibility-by-moving-to-the-cloud/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Basic tips to avoid adware and other harmful things</title>
		<link>http://www.gadratilprogramming.net/basic-tips-to-avoid-adware-and-other-harmful-things/</link>
		<comments>http://www.gadratilprogramming.net/basic-tips-to-avoid-adware-and-other-harmful-things/#comments</comments>
		<pubDate>Thu, 06 Oct 2016 06:13:32 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[adware]]></category>
		<category><![CDATA[antivirus]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tool]]></category>
		<category><![CDATA[virus]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=280</guid>
		<description><![CDATA[In our modern world more and more digital goods become free, but packed with ads. Ads by themselves are not harmful, but there are cases when they can become so. Adware is an expression for software that is harmful for your PC or Phone. It makes you vulnerable to other harmful software and fills your [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In our modern world more and more digital goods become free, but packed with ads. Ads by themselves are not harmful, but there are cases when they can become so.</p>
<p>Adware is an expression for software that is harmful for your PC or Phone. It makes you vulnerable to other harmful software and fills your browsers with popups, add-ons, bars and all kinds of annoying things. Also, these can significantly slow down your computer or phone.</p>
<p>Usually people get these adware from the internet in different forms. They come with some free software you download, or simply you click on a wrong link on a webpage.</p>
<p>Let&#8217;s talk about browsing habits. It is very important to follow these rules when browsing the internet:</p>
<ul>
<li>Be patient. Clicking like a maniac on a link can make you click on something you did not want.</li>
<li>Never register anywhere if you do not trust that website</li>
<li>If you are uncertain about a website, search for it on forums, find out what other people think</li>
<li>Never click on flashy, fancy, big buttons on a website</li>
<li>Modern browsers have everything to watch videos or to play games, you DO NOT have to download extra plugins or stuff like that. Those are probably full of viruses and adware.</li>
<li>DO NOT download things you do not know or do not trust</li>
<li>Always use a virus scanning tool, those can help you prevent downloading unwanted software</li>
<li>If you are uncertain, ask someone who knows better</li>
</ul>
<p>Following these browsing habits do not guarantee success on being clean of viruses and other harmful software. Once you get infected, there are things you can do to clean your computer or phone:</p>
<ul>
<li>Uninstall all programs you do not use or do not know.</li>
<li>Use the antivirus tool`s full scan to find viruses</li>
<li>Use dedicated adware removal tools, like <a href="https://www.techsupportall.com/adware-removal-tool/">Adware Removal Tool</a></li>
<li>Run a cleaning tool to clean temporary files from your system</li>
<li>Again, ask someone who knows better</li>
</ul>
<p>There are so many types of scams that it is not easy to filter them all, so it happens that you get infected anyway or you cannot disinfect your device by your own. It is better to ask the help of a professional in these cases, otherwise you can lose more than paying a simple service.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/basic-tips-to-avoid-adware-and-other-harmful-things/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebook: how to use graph search</title>
		<link>http://www.gadratilprogramming.net/facebook-how-to-use-graph-search/</link>
		<comments>http://www.gadratilprogramming.net/facebook-how-to-use-graph-search/#comments</comments>
		<pubDate>Tue, 04 Oct 2016 08:24:28 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[graph search]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=276</guid>
		<description><![CDATA[This article will not be a very technical one, more like a showcase of what you can do with Facebook&#8217;s Graph Search functionality. First of all, you have to activate it. Currently Graph Search only works on English language, so you have to enable it by changing your language to English(US). After you changed the [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>This article will not be a very technical one, more like a showcase of what you can do with Facebook&#8217;s Graph Search functionality.</p>
<p>First of all, you have to activate it. Currently Graph Search only works on English language, so you have to enable it by changing your language to English(US). After you changed the language, you just type the things you want to search in the search field.</p>
<p>Graph Search is a bit like an SQL query, but in a more human language. For example you can type in: people in last month liked by &lt;name of someone&gt;. This will find all the people who were liked by the person you type in. Usually these searches are narrowed to your friends, so probably you will not be able to see the pictures liked by a celebrity who is not your friend.</p>
<p>Some other examples:</p>
<ul>
<li> photos of males / females liked by &lt;name of friend&gt;</li>
<li>events liked by &lt;name of friend&gt;</li>
<li>photos of me liked by &lt;person 1&gt; and &lt;person 2&gt;</li>
<li>books &lt;person&gt; and I are interested in</li>
</ul>
<p>Graph Search is almost limitless, you can search a lot of things with it. Take care however, because you can find things you are not prepared or <img src="http://www.gadratilprogramming.net/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Good searching for everyone. If you need help with given examples, just write in the comments or on Facebook at <a href="https://www.facebook.com/gadratilprogramming/">https://www.facebook.com/gadratilprogramming/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/facebook-how-to-use-graph-search/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handling tree structures in PHP</title>
		<link>http://www.gadratilprogramming.net/handling-tree-structures-in-php/</link>
		<comments>http://www.gadratilprogramming.net/handling-tree-structures-in-php/#comments</comments>
		<pubDate>Mon, 13 Jun 2016 12:27:38 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[db]]></category>
		<category><![CDATA[infinity]]></category>
		<category><![CDATA[node]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recursivity]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[tree]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=252</guid>
		<description><![CDATA[What is a tree? A tree is a scructure of data used for categories, showing hierarchy and so on. In web applications usually the most used case is creating category hierarchy, menu hierarchy or page hierarchy. Currently there are a lot of ways to create tree scructures in PHP, but we will use just one [&#8230;]]]></description>
				<content:encoded><![CDATA[<h3>What is a tree?</h3>
<p>A tree is a scructure of data used for categories, showing hierarchy and so on. In web applications usually the most used case is creating category hierarchy, menu hierarchy or page hierarchy. Currently there are a lot of ways to create tree scructures in PHP, but we will use just one example, one that is very flexible and adaptable for many usecases.</p>
<h3>Example of a tree</h3>
<p>For the sake of simplicity, we will use a very simple tree for example. Our tree looks like this:</p>
<p><a href="http://www.gadratilprogramming.net/wp-content/uploads/2016/06/Untitled-Diagram.png"><img class="aligncenter size-full wp-image-254" src="http://www.gadratilprogramming.net/wp-content/uploads/2016/06/Untitled-Diagram.png" alt="Tree" width="153" height="303" /></a>This is a one depth tree with four nodes in total. In trees, the nodes that have children are called branches and the ones that have none are called leaves.</p>
<h3>How to store a tree</h3>
<p>When working with simple trees, storing the hierarchy is not that hard. Usually, in the database we can create a parent column that contains the parent of a given node. In tree structures, every node can have only one parent, the only exception being the root. The root node has no parent.</p>
<p>Now, if we know how deep our tree will be, using just the parent for information, we are set. If we do not know the depth exactly, things are a bit more complicated. Since people created databases, a lot of storing methods have been born that help store recursive data linearly. Each is different in a way and each is good at something, but bad at other.</p>
<p>Our example is a basic linear representation and is pretty quick. It contains some extra info that some might consider an overhead, but it is simple, logical, and it works.</p>
<table class="table" style="background-color: #b8f5e3;" width="100%">
<thead>
<tr>
<th>Id</th>
<th>Parent</th>
<th>Tree</th>
<th>Slug</th>
<th>Name</th>
<th>Path</th>
<th>Children</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>NULL</td>
<td>1</td>
<td>root</td>
<td>Root</td>
<td></td>
<td>|2,3|</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>1</td>
<td>node1</td>
<td>Node1</td>
<td>|1|</td>
<td>|4,5|</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>1</td>
<td>nod2</td>
<td>Node2</td>
<td>|1|</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>2</td>
<td>1</td>
<td>child1</td>
<td>Child1</td>
<td>|1-2|</td>
<td></td>
</tr>
<tr>
<td>5</td>
<td>2</td>
<td>1</td>
<td>child2</td>
<td>Child2</td>
<td>|1-2|</td>
<td></td>
</tr>
</tbody>
</table>
<p>This is how we store the data. Every row is a node. The columns are as following:</p>
<p><strong>Id:</strong> this is the autoincrement unique id of every node.</p>
<p><strong>Parent:</strong> This contains one integer, the Id of the parent node. This is mainly formality and is used in simple cases.</p>
<p><strong>Tree:</strong> with this field, we can have more than one tree in one table. This is an integer and is the id of the tree we work with. Every tree has a root node that is mandatory</p>
<p><strong>Slug:</strong> this is a slug, created from the given name and is always unique in the table. This is an additional unique field besides the Id.</p>
<p><strong>Name:</strong> this is the name of the node.</p>
<p><strong>Path:</strong> this column coontains the ids of the nodes that are before our node on the branch from the root, merged into a string. This contains the full path from the root till the node. This is handy in building the hierarchy in PHP.</p>
<p><strong>Children:</strong> contains all the ids of the children of a node, merged into a string. This also stores the order of the children.</p>
<h3>Handling tree in PHP</h3>
<p>In PHP, we can easily manipulate this data. We will have some basic examples to show the perks of this type of DB structure.</p>
<p>For start, how do you get the tree? With one simple query, we can get the whole tree, or just a subtree, using the id of the root node. The nodes that have paths that contain the given id, all belong to the same subtree. This looks like this:</p><pre class="crayon-plain-tag">SELECT * FROM `table_name` WHERE 
			`path` LIKE "%-:parent-%"
			OR `path` LIKE "%|:parent-%"
			OR `path` LIKE "%-:parent|%"
			OR `path` LIKE "%|:parent|%"</pre><p>When we have the data, we have to convert the strings into actual PHP arrays for us to be able to easily use them later. We do this like:</p><pre class="crayon-plain-tag">$node-&gt;path = array_filter(explode('-', str_replace('|', '', $node-&gt;path)));
$node-&gt;children = array_filter(explode(',', str_replace('|', '', $node-&gt;children)));

$node-&gt;path = array_filter(explode('-', str_replace('|', '', $node-&gt;path)));
$node-&gt;children = array_filter(explode(',', str_replace('|', '', $node-&gt;children)));</pre><p>One other important aspect is moving the nodes from a parent to another, being able to move the whole subtree if necessary. In our case this is not hard, we just have to update some strings. In PHP this means slicing and rearranging our arrays of children and path. Something like this:</p><pre class="crayon-plain-tag">// Get old parent
$old_parent = $this-&gt;getNode($node-&gt;parent);
			
$old_parent-&gt;children = array_diff($old_parent-&gt;children, array($node-&gt;id));
$this-&gt;_storage-&gt;begin_transaction();
			
try
{
	$this-&gt;_storage-&gt;updateNode($old_parent);
				
	$arr2 = array_slice($to-&gt;children, $order-1);
	$arr1 = array_diff($to-&gt;children, $arr2);
	$to-&gt;children = array_merge($arr1, array($node-&gt;id), $arr2);
				
	$this-&gt;_storage-&gt;updateNode($to);
				
	$node-&gt;parent = $to-&gt;id;
	$node-&gt;path = array_merge($to-&gt;path, array($to-&gt;id));
	$this-&gt;_storage-&gt;updateNode($node);
				
	foreach( $subtree as $subnode )
	{
		$subnode-&gt;path = array_merge(
			$to-&gt;path,
			array($to-&gt;id, $node-&gt;id),
			array_diff($subnode-&gt;path, array_merge($node-&gt;path, array($node-&gt;id)))
		);
					
		$this-&gt;_storage-&gt;updateNode($subnode);
	}
				
	$this-&gt;_storage-&gt;commit_transaction();
				
	return true;
}
catch(Exception $e)
{
	$this-&gt;_storage-&gt;rollback_transaction();
	$this-&gt;_errors['move'] = $e-&gt;getMessage();
	return false;
}</pre><p>Ordering is also easy. Ordering is done on a given level, so we use the children column to order the nodes. The code would look like this:</p><pre class="crayon-plain-tag">$children = array_diff($to-&gt;children, array($node-&gt;id));
$arr2 = array_slice($children, $order-1);
$arr1 = array_diff($children, $arr2);
$to-&gt;children = array_merge($arr1, array($node-&gt;id), $arr2);
			
$this-&gt;_storage-&gt;updateNode($to);</pre><p>Upon deletion, using the move section, you can prompt the user to move the subtree to root, or delete the whole subtree.</p>
<p>Using LIKE syntax in SQL, you can achieve a lot of things.</p>
<p>One last thing that needs mentioning is the recursive function that builds the N depth out of linear data we just got from DB. Here it is:</p><pre class="crayon-plain-tag">private function _build_tree(Node $root, $data)
{
	$mapped_node = array(
		'node' =&gt; $root,
		'subnodes' =&gt; array()
	);
		
	if ( !empty($root-&gt;children) )
	{
		foreach( $root-&gt;children as $child )
		{
			if ( array_key_exists($child, $data) )
			{
				$mapped_node['subnodes'][] = $this-&gt;_build_tree($data[$child], $data);
			}
		}
	}
		
	return $mapped_node;
}</pre><p></p>
<h3>Conclusion</h3>
<p>You can find all these pieces of code in the <a href="https://gitlab.com/Gadratil/PHPInfinityTree" target="_blank">PHPInfinityTree</a> repository on GitLab. This is probably not the best solution, but is simple, understandable and is quick. Since recursivity cannot be used in many databases, we have to store the data linearly. Then we go trough it linearly and build up the tree itself.</p>
<p>You can find a working example on <a href="http://infinitytree.gadratilprogramming.net" target="_blank">PHPInfinityTree.</a></p>
<p>Also, you can find the packed and documented package of <a href="http://www.gadratilprogramming.net/shop/php-libraries/php-infinity-tree/" target="_blank">Infinity Tree in the Store</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/handling-tree-structures-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to structure a basic PHP file</title>
		<link>http://www.gadratilprogramming.net/how-to-structure-a-basic-php-file/</link>
		<comments>http://www.gadratilprogramming.net/how-to-structure-a-basic-php-file/#comments</comments>
		<pubDate>Thu, 02 Jun 2016 12:48:20 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code structure]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[readability]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=243</guid>
		<description><![CDATA[When creating code, PHP gives us a huge freedom. Since PHP is compiled at runtime, it can be mixed with any text inside the file. Then, when the code is compiled, the content of the file gets to the output (usually your browser). If you create a small project, using this technique is totally ok. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>When creating code, PHP gives us a huge freedom. Since PHP is compiled at runtime, it can be mixed with any text inside the file. Then, when the code is compiled, the content of the file gets to the output (usually your browser).</p>
<p>If you create a small project, using this technique is totally ok. The problem starts when the project starts to grow.</p>
<p>This article is about a small sized project with very few PHP files. In any case, readability is a very important thing. You know the case when you get back to your code after a long time to edit something, and you just are lost. To make the code readable and logically sound, there is a structure that can be used to achieve it.</p>
<p>If the PHP file contains HTML in it, usually it is good to separate the two. The file starts with PHP, containing all the logic needed. All the data that needs to be printed on the screen is added into variables. These variables are then used in the HTML. This clearly separates the logic from the actual data output. So the structure looks something like:</p><pre class="crayon-plain-tag">&amp;lt;?php 
// PHP code here $variable = 'Hello, world'; 
$variable = 'Hello, world!';
?&amp;gt;
&amp;lt;!-- HTML part here --&amp;gt;
&amp;lt;div&amp;gt;&amp;lt;?php echo $variable; ?&amp;gt;&amp;lt;/div&amp;gt;</pre><p>In the PHP section, where the logic is, you can also separate the logic that handles POST requests for example. It is good practice to create variables that will control such events and that hold information about these events. These variables than can control the HTML part accordingly. For example:</p><pre class="crayon-plain-tag">&nbsp;&amp;lt;?php
$error = '';
$post_var = '';
$was_post = false;
// Some data collecting logic
$variable = 'Hello, world!';
if ($_POST)
{
&nbsp;&nbsp; &nbsp;$error = 'Sample error.';
&nbsp;&nbsp; &nbsp;$post_var = 'Goodbye';
&nbsp;&nbsp; &nbsp;$was_post = true;
}
?&amp;gt;
&amp;lt;?php if ($error != ''): ?&amp;gt;
&nbsp;&nbsp; &nbsp;&amp;lt;div style=&quot;color:red;&quot;&amp;gt;&amp;lt;?php echo $error; ?&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;?php endif! ?&amp;gt;
&amp;lt;div&amp;gt;&amp;lt;?php echo $variable; ?&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;?php if ( $was_post ): ?&amp;gt;
&nbsp;&nbsp; &nbsp;&amp;lt;div&amp;gt;&amp;lt;?php echo $post_var; ?&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;?php endif; ?&amp;gt;
&amp;lt;form action=&quot;&quot; method=&quot;post&quot;&amp;gt;
&nbsp;&nbsp; &nbsp;&amp;lt;input type=&quot;submit&quot; value=&quot;POST&quot;&amp;gt;
&amp;lt;/form&amp;gt;</pre><p>This makes your code clear and if needed, later you can separate the logic from the actual html. Using such a structure is beneficial for you. Since PHP is a very loose language, you are the one that needs to pay attention to such things, but you will not regret it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/how-to-structure-a-basic-php-file/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Blog section on gadratil programming</title>
		<link>http://www.gadratilprogramming.net/blog-section-on-gadratil-programming/</link>
		<comments>http://www.gadratilprogramming.net/blog-section-on-gadratil-programming/#comments</comments>
		<pubDate>Mon, 30 May 2016 12:53:12 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[gadratil]]></category>
		<category><![CDATA[latest]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gadratilprogramming.net/?p=216</guid>
		<description><![CDATA[We are proud to present our blog section! We want to use this section for articles about programming, our experiences learned so far and things about the site, too. You will be able to see the latest news, latest tutorials, new products and everything that is related to gardatil programming. So enjoy, and come back [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>We are proud to present our blog section! We want to use this section for articles about programming, our experiences learned so far and things about the site, too.</p>
<p>You will be able to see the latest news, latest tutorials, new products and everything that is related to gardatil programming.</p>
<p>So enjoy, and come back from time to time to see if there is anything new around.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/blog-section-on-gadratil-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What we offer</title>
		<link>http://www.gadratilprogramming.net/what-we-offer/</link>
		<comments>http://www.gadratilprogramming.net/what-we-offer/#comments</comments>
		<pubDate>Mon, 13 Apr 2015 19:27:55 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Sliders]]></category>

		<guid isPermaLink="false">http://www.gpw.dev/?p=41</guid>
		<description><![CDATA[These are the things we offer for our clients: Self-made code packages; Basic SEO; Website creation; Bugfixes on existing setups; Programming help;]]></description>
				<content:encoded><![CDATA[<p>These are the things we offer for our clients:</p>
<ul>
<li>Self-made code packages;</li>
<li>Basic SEO;</li>
<li>Website creation;</li>
<li>Bugfixes on existing setups;</li>
<li>Programming help;</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/what-we-offer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Frameworks Used</title>
		<link>http://www.gadratilprogramming.net/frameworks-used/</link>
		<comments>http://www.gadratilprogramming.net/frameworks-used/#comments</comments>
		<pubDate>Mon, 13 Apr 2015 19:19:01 +0000</pubDate>
		<dc:creator><![CDATA[Gadratil]]></dc:creator>
				<category><![CDATA[Sliders]]></category>

		<guid isPermaLink="false">http://www.gpw.dev/?p=37</guid>
		<description><![CDATA[We have used the following frameworks: Kohana; WordPress; PrestaShop; Codeigniter; CakePHP; Aura; Yii; Laravel]]></description>
				<content:encoded><![CDATA[<h3>We have used the following frameworks:</h3>
<ul>
<li>Kohana;</li>
<li>WordPress;</li>
<li>PrestaShop;</li>
<li>Codeigniter;</li>
<li>CakePHP;</li>
<li>Aura;</li>
<li>Yii;</li>
<li>Laravel</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gadratilprogramming.net/frameworks-used/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
