<?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>php class Archives - Postnidea</title>
	<atom:link href="https://www.postnidea.com/category/php-class/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.postnidea.com/category/php-class/</link>
	<description>Programming Blog, Tutorials, jQuery, Ajax, PHP, MySQL and Demos</description>
	<lastBuildDate>Tue, 27 May 2025 09:13:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.2.8</generator>

<image>
	<url>https://www.postnidea.com/wp-content/uploads/2019/08/favicon.ico</url>
	<title>php class Archives - Postnidea</title>
	<link>https://www.postnidea.com/category/php-class/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>php data scraping techniques</title>
		<link>https://www.postnidea.com/php-data-scraping-techniques/</link>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Sun, 15 Apr 2018 18:47:00 +0000</pubDate>
				<category><![CDATA[Data mining]]></category>
		<category><![CDATA[Data scraping]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[php data scraping]]></category>
		<category><![CDATA[Data Mining]]></category>
		<category><![CDATA[Data Scraping]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>Data is very important for an organization. With the help of data, an organization can generate a lot of business. [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-data-scraping-techniques/">php data scraping techniques</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p>Data is very important for an organization. With the help of data, an organization can generate a lot of business. It works same as like fuel for an engine. Quality of data will increase your business. But the question comes out how to collect data. There are various ways you can collect the data for our organization or business. There is a lot of platforms that provide you paid data.  They charge a small amount of money &amp; will provide you a data. Another way to scarp data from document, website or text file.</p>
<p>Data scraping is that way from which you can extract the required data. The data available on the web pages, XML feed, post feeds but there is a no way to save data in a required format so that it can easy to navigate  &amp; usage. With the help of data scraping, you can extract &amp; save data in the data source and can be used for our business strategy.</p>
<h2 style="text-align: left;">Why people do scrap</h2>
<div style="text-align: left;"></div>
<ul>
<li>collect the current price of the products so that competitors can analyze the market.</li>
<li>Get always updated data when no API  communication source is available.</li>
<li>Generate the business lead from the contact details.</li>
<li>survey usage so  that you can collect the poll data</li>
</ul>
<p>&nbsp;</p>
<h2 style="text-align: left;">How can be achieved?</h2>
<p>There is different language platform provides a different way. I belong to PHP so, I will show a method that used PHP.  With the Use of PHP, you can use three-way from which you extract the data.</p>
<div style="text-align: left;"></div>
<ul>
<li>Document Parsing</li>
<li>Jquery Like PHP Library(simple_html_dom)</li>
<li>Regular Expressions</li>
</ul>
<p>&nbsp;</p>
<div style="text-align: left;"></div>
<p>Before explaining above three techniques I want to take some HTML structure. So that I can use in explaining techniques.</p>
<p><script src="https://pastebin.com/embed_js/Gc2THL6M"></script></p>
<p>Above code will display a list of users. Now I try to extract above users &amp; show in the array.</p>
<p>Now before starting this, we need to get the html structure using URL. In PHP there is two functions are available which get the HTML of the page using URL file_get_contents, another using curl. Curl is very effective because it works faster, extract HTML structure even SSL available. So, Now I create a function return an HTML structure of the page using URL using curl.</p>
<p><script src="https://pastebin.com/embed_js/ZTuDMU6Z"></script></p>
<p>Now with the use of above function, you can get the HTML structure of the page. Now I  explain you data extraction technique one by one.</p>
<h2 style="text-align: left;">PHP Document Parsing</h2>
<p>It simply loads the HTML document &amp; parses into a tree. You can simply say it convert HTML document to XML. With applying query you can extract the data. But its&#8217;s time-consuming process because first it loads &amp; parses structure then your query will work. For long HTML structure document, it consumes a lot of memory. Now I show example code that will show you how it works.</p>
<h2 style="text-align: left;">Jquery Like PHP Library(simple_html_dom) for data scrap</h2>
<p>It&#8217;s also a same above like document parsing. But With the help of class like simple_html_dom, Scraper, hQuery make easy to use. If you are comfortable with jquery then the class will make your life easy. They work like just a jquery functions. Now I show you an example that uses the simple_html_dom library. You can download library using below link &amp; include in our code.</p>
<p>https://sourceforge.net/projects/simplehtmldom/</p>
<h2 style="text-align: left;">Regular Expressions</h2>
<p>It&#8217;s very fast processing data scrap techniue. It&#8217;s not parsing the HTML structure into XML or tree. It treat HTML structure as string &amp; perform serach operation. But for creating regular expression according business logic it&#8217;s very time consuming. Currenty I have taken simple structure.</p>
<p><script src="https://pastebin.com/embed_js/Pcm1uaY5"></script></p>
<p>Now finally I will recommend regular expression technique if you plan for large data extraction. Last but not least never use the browser for data extraction always try to use terminal or command prompt for data scrapping so that your script will run for the longtime &amp; data will be extracted without distortion.</p>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-data-scraping-techniques/">php data scraping techniques</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>PHP class for form validation</title>
		<link>https://www.postnidea.com/php-class-for-form-validation/</link>
					<comments>https://www.postnidea.com/php-class-for-form-validation/#comments</comments>
		
		<dc:creator><![CDATA[Rakesh Kumar]]></dc:creator>
		<pubDate>Sun, 31 Jul 2016 13:50:00 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php class]]></category>
		<category><![CDATA[validation]]></category>
		<category><![CDATA[Form validation]]></category>
		<category><![CDATA[php server side validation]]></category>
		<category><![CDATA[PHP validation class]]></category>
		<guid isPermaLink="false"></guid>

					<description><![CDATA[<p>PHP plays great role in the form values sensitization. PHP provide filters with the help of that you plays with [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-class-for-form-validation/">PHP class for form validation</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div dir="ltr" style="text-align: left;">
<p>PHP plays great role in the form values sensitization. PHP provide filters with the help of that you plays with form validation &amp; sensitization of form values. PHP provides three types of filter which is below.</p>
<ul>
<li> Validate filters</li>
<li> Sanitize filters</li>
<li> Other filters</li>
</ul>
<p><b>Validate filters</b><br />
PHP provide in built function for some values validate like email, url, IP address, int , float &amp; regx validation.<br />
for more information</p>
<p><b>Sanitize filters</b><br />
Sanitize filters are used for making valid input so that in future it will create the hole in application. With maintian validation user can be input such a values that can break the functionlity like not inserted in the database or can input the code that can be used in the future. So Sanitize filters can be filter the user inputs.</p>
<p><b>Other filters </b><br />
PHP faciliate to developer he can be add our custom function. That function can be call at time of validation.</p>
<p>So with the usage of these function ii try to create  a class that can be used for validation form. The class that i have written in which covered the below validation.</p>
<ul>
<li>Email validation</li>
<li>Required validation</li>
<li>Numeric validation</li>
<li>positive numeric validation</li>
<li>positive integer validation</li>
<li>URL</li>
<li>Alpha</li>
<li>Alphanumeric</li>
<li>Unique value in database</li>
<li>two parameter field value comparison</li>
<li>Max &amp; Min character limit</li>
<li>Photos</li>
<li>upload validation</li>
</ul>
<h2>PHP Form validation Library</h2>
<p>So below i will show you structure of the class how to be processed. We cretae the seprate function each above validation. which is shown to you in below code.</p>
<p>You can get here code of <a class="btn btn-primary btn-blue" href="https://gist.github.com/rakeshkumar125/2673a98bccfd3a1e13c03b335d7d8f6a">PHP Form Validation Library</a></p>
<h2>Use of PHP Form validation Library</h2>
<p>Now show to how to be use this class. So, First need to initialize the Class with config array, from the config array it will get the data &amp; process it. For different validation how to call. In below code first need to initialize the array. Then provide the one dimensional array to validate for array variable [array_to_validate]. Here just need to pass the name of the element the class will process there values &amp; return the validation status. For example [$config[&#8217;email&#8217;]] assign account_email, alternative_email textbox name so that it can be validate.</p>
<p>Now let me show you with code.</p>
<pre><code>$config = array();
$config['array_to_validate'] = $_POST or array_need_to_validate;
$config['email'] 	     = "email,forgot_email";
$config['required']	     = "date_birth,phone,mobile";
$config['numeric']	     = "mobile";
$config['positive_numeric']  = "positive_number";
$config['positive_integer']  = "positive_integer";
$config['url']		     = "url";
$config['alpha']	     = "name";
$config['alphanumeric']	     = "user_password";
</code></pre>
<p>Now its some thing different because this validation the database. field_name means provide the textbox name or element that need to validation.</p>
<p>Implimentation of unique value in database like user name:</p>
<pre>$config['unique_from_table']= array(
				array(
				'field_name' =&gt;'',
				'table_name' =&gt;'user',
				'table_field'=&gt;'username'
				),
				array(
				'field_name' =&gt;'',
				'table_name' =&gt;'users',
				'table_field'=&gt;'username'
				)
			);
</pre>
<h2>Comparasion</h2>
<pre><code>
$config['compare']= array(
			array(
				'field_name' =&gt;'username',
				'compare_field_name' =&gt;'firstname',
			),
			array(
			  'field_name' =&gt;'lastname',
			  'compare_field_name' =&gt;'firstname'
			)
		);
</code></pre>
<h2>Character Limit Validation</h2>
<pre><code>
$config['min_character_limit']= array(
				    array(
					'field_name' =&gt;'username',
					'no_of_character' =&gt;'20',
				    ),
				    array(
					'field_name' =&gt;'lastname',
					'no_of_character' =&gt;'30'
				    )
				);

$config['max_character_limit'] = array(
								array(
									'field_name' =&gt;'username',
									'no_of_character' =&gt;'20',
								),
								array(
									'field_name' =&gt;'lastname',
									'no_of_character' =&gt;'30'
								)
							);

</code></pre>
<p>Finally call the class &amp; pass all things which we have built in above. Then class will process your inputs &amp; return the result. If there is validation error then return array of error otherwise pass it.</p>
<pre><code>
$my_validator = new validator($config)
$error = $my_validator-&gt;process_validation();
</code></pre>
</div>
<p>The post <a rel="nofollow" href="https://www.postnidea.com/php-class-for-form-validation/">PHP class for form validation</a> appeared first on <a rel="nofollow" href="https://www.postnidea.com">Postnidea</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.postnidea.com/php-class-for-form-validation/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
