<?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:blogger='http://schemas.google.com/blogger/2008' 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-8249511261829305238</id><updated>2024-09-22T07:08:32.397+07:00</updated><category term="PHP"/><category term="CUSTOM ROM ANDROID"/><category term="JAVA"/><category term="Eclipse Ant"/><category term="MYSQL"/><category term="SHELL SCRIPT"/><category term="LINUX"/><category term="BADA"/><category term="CODEIGNITER"/><category term="OMAP"/><category term="ORACLE"/><category term="PostgreSQL"/><category term="XML"/><title type='text'>Neo-Nevz</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>38</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-1252023289718594151</id><published>2012-11-07T16:25:00.003+07:00</published><updated>2012-11-07T16:25:27.628+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>How do I convert array into JSON?</title><content type='html'>&lt;h2&gt;
&lt;br /&gt;&lt;/h2&gt;
&lt;h5&gt;
Date: &lt;strong&gt;2010-09-16&lt;/strong&gt;. Category: &lt;strong&gt;com.google.gson&lt;/strong&gt; examples. Hits: &lt;strong&gt;12K&lt;/strong&gt; time(s).&lt;/h5&gt;
In the example below you can see how to convert an array into JSON string. We serialize the array to JSON using the &lt;code&gt;Gson.toJson()&lt;/code&gt; method. To deserialize a string of JSON into array we use the &lt;code&gt;Gson.fromJson()&lt;/code&gt; method.&lt;br /&gt;


&lt;div class=&quot;toolbar&quot;&gt;
&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
14&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
15&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
16&lt;/div&gt;
&lt;div class=&quot;line number17 index16 alt2&quot;&gt;
17&lt;/div&gt;
&lt;div class=&quot;line number18 index17 alt1&quot;&gt;
18&lt;/div&gt;
&lt;div class=&quot;line number19 index18 alt2&quot;&gt;
19&lt;/div&gt;
&lt;div class=&quot;line number20 index19 alt1&quot;&gt;
20&lt;/div&gt;
&lt;div class=&quot;line number21 index20 alt2&quot;&gt;
21&lt;/div&gt;
&lt;div class=&quot;line number22 index21 alt1&quot;&gt;
22&lt;/div&gt;
&lt;div class=&quot;line number23 index22 alt2&quot;&gt;
23&lt;/div&gt;
&lt;div class=&quot;line number24 index23 alt1&quot;&gt;
24&lt;/div&gt;
&lt;div class=&quot;line number25 index24 alt2&quot;&gt;
25&lt;/div&gt;
&lt;div class=&quot;line number26 index25 alt1&quot;&gt;
26&lt;/div&gt;
&lt;div class=&quot;line number27 index26 alt2&quot;&gt;
27&lt;/div&gt;
&lt;div class=&quot;line number28 index27 alt1&quot;&gt;
28&lt;/div&gt;
&lt;div class=&quot;line number29 index28 alt2&quot;&gt;
29&lt;/div&gt;
&lt;div class=&quot;line number30 index29 alt1&quot;&gt;
30&lt;/div&gt;
&lt;div class=&quot;line number31 index30 alt2&quot;&gt;
31&lt;/div&gt;
&lt;div class=&quot;line number32 index31 alt1&quot;&gt;
32&lt;/div&gt;
&lt;div class=&quot;line number33 index32 alt2&quot;&gt;
33&lt;/div&gt;
&lt;div class=&quot;line number34 index33 alt1&quot;&gt;
34&lt;/div&gt;
&lt;div class=&quot;line number35 index34 alt2&quot;&gt;
35&lt;/div&gt;
&lt;div class=&quot;line number36 index35 alt1&quot;&gt;
36&lt;/div&gt;
&lt;div class=&quot;line number37 index36 alt2&quot;&gt;
37&lt;/div&gt;
&lt;div class=&quot;line number38 index37 alt1&quot;&gt;
38&lt;/div&gt;
&lt;div class=&quot;line number39 index38 alt2&quot;&gt;
39&lt;/div&gt;
&lt;div class=&quot;line number40 index39 alt1&quot;&gt;
40&lt;/div&gt;
&lt;div class=&quot;line number41 index40 alt2&quot;&gt;
41&lt;/div&gt;
&lt;div class=&quot;line number42 index41 alt1&quot;&gt;
42&lt;/div&gt;
&lt;div class=&quot;line number43 index42 alt2&quot;&gt;
43&lt;/div&gt;
&lt;div class=&quot;line number44 index43 alt1&quot;&gt;
44&lt;/div&gt;
&lt;div class=&quot;line number45 index44 alt2&quot;&gt;
45&lt;/div&gt;
&lt;div class=&quot;line number46 index45 alt1&quot;&gt;
46&lt;/div&gt;
&lt;div class=&quot;line number47 index46 alt2&quot;&gt;
47&lt;/div&gt;
&lt;div class=&quot;line number48 index47 alt1&quot;&gt;
48&lt;/div&gt;
&lt;div class=&quot;line number49 index48 alt2&quot;&gt;
49&lt;/div&gt;
&lt;div class=&quot;line number50 index49 alt1&quot;&gt;
50&lt;/div&gt;
&lt;div class=&quot;line number51 index50 alt2&quot;&gt;
51&lt;/div&gt;
&lt;div class=&quot;line number52 index51 alt1&quot;&gt;
52&lt;/div&gt;
&lt;div class=&quot;line number53 index52 alt2&quot;&gt;
53&lt;/div&gt;
&lt;div class=&quot;line number54 index53 alt1&quot;&gt;
54&lt;/div&gt;
&lt;div class=&quot;line number55 index54 alt2&quot;&gt;
55&lt;/div&gt;
&lt;div class=&quot;line number56 index55 alt1&quot;&gt;
56&lt;/div&gt;
&lt;div class=&quot;line number57 index56 alt2&quot;&gt;
57&lt;/div&gt;
&lt;div class=&quot;line number58 index57 alt1&quot;&gt;
58&lt;/div&gt;
&lt;div class=&quot;line number59 index58 alt2&quot;&gt;
59&lt;/div&gt;
&lt;div class=&quot;line number60 index59 alt1&quot;&gt;
60&lt;/div&gt;
&lt;div class=&quot;line number61 index60 alt2&quot;&gt;
61&lt;/div&gt;
&lt;div class=&quot;line number62 index61 alt1&quot;&gt;
62&lt;/div&gt;
&lt;div class=&quot;line number63 index62 alt2&quot;&gt;
63&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;java keyword&quot;&gt;package&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;org.kodejava.example.google.gson;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;java keyword&quot;&gt;import&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;com.google.gson.Gson;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;java keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;ArrayToJson {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;public&lt;/code&gt; &lt;code class=&quot;java keyword&quot;&gt;static&lt;/code&gt; &lt;code class=&quot;java keyword&quot;&gt;void&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;main(String[] args) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[] numbers = {&lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;1&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;1&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;2&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;3&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;5&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;8&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;13&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;};&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;String[] days = {&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Sun&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Mon&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Tue&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Wed&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Thu&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Fri&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Sat&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;};&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Create a new instance of Gson&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;Gson gson = &lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;new&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;Gson();&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Convert numbers array into JSON string.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number17 index16 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number18 index17 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;String numbersJson = gson.toJson(numbers);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number19 index18 alt2&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number20 index19 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number21 index20 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Convert strings array into JSON string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number22 index21 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number23 index22 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;String daysJson = gson.toJson(days);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number24 index23 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;numbersJson = &quot;&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;+ numbersJson);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number25 index24 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;daysJson = &quot;&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;+ daysJson);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number26 index25 alt1&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number27 index26 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number28 index27 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Convert from JSON string to a primitive array of int.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number29 index28 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number30 index29 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[] fibonacci = gson.fromJson(numbersJson, &lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[].&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number31 index30 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;for&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;i = &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;0&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;; i &amp;lt; fibonacci.length; i++) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number32 index31 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.print(fibonacci[i] + &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot; &quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number33 index32 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number34 index33 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number35 index34 alt2&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number36 index35 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number37 index36 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Convert from JSON string to a string array.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number38 index37 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number39 index38 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;String[] weekDays = gson.fromJson(daysJson, String[].&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number40 index39 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;for&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;i = &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;0&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;; i &amp;lt; weekDays.length; i++) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number41 index40 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.print(weekDays[i] + &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot; &quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number42 index41 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number43 index42 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number44 index43 alt1&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number45 index44 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number46 index45 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Converting multidimensional array into JSON&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number47 index46 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number48 index47 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[][] data = {{&lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;1&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;2&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;3&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}, {&lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;3&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;4&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;5&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}, {&lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;4&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;5&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;6&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}};&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number49 index48 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;String json = gson.toJson(data);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number50 index49 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;Data = &quot;&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;+ json);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number51 index50 alt2&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;line number52 index51 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number53 index52 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;// Convert JSON string into multidimensional array of int.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number54 index53 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java comments&quot;&gt;//&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number55 index54 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[][] dataMap = gson.fromJson(json, &lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;[][].&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;class&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number56 index55 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;for&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;i = &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;0&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;; i &amp;lt; data.length; i++) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number57 index56 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;for&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;java keyword&quot;&gt;int&lt;/code&gt; &lt;code class=&quot;java plain&quot;&gt;j = &lt;/code&gt;&lt;code class=&quot;java value&quot;&gt;0&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;; j &amp;lt; data[i].length; j++) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number58 index57 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.print(data[i][j] + &lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot; &quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number59 index58 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number60 index59 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;System.out.println(&lt;/code&gt;&lt;code class=&quot;java string&quot;&gt;&quot;&quot;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number61 index60 alt2&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number62 index61 alt1&quot;&gt;
&lt;code class=&quot;java spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number63 index62 alt2&quot;&gt;
&lt;code class=&quot;java plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/1252023289718594151/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/11/how-do-i-convert-array-into-json.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/1252023289718594151'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/1252023289718594151'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/11/how-do-i-convert-array-into-json.html' title='How do I convert array into JSON?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-6871923978849230615</id><published>2012-07-09T13:32:00.001+07:00</published><updated>2012-07-09T13:32:59.261+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>XML ERROR</title><content type='html'>&lt;br /&gt;
XML Parsing Error: not well-formed &lt;br /&gt;
&lt;br /&gt;
Answer :&lt;br /&gt;
&lt;a href=&quot;http://stackoverflow.com/questions/4267244/xml-parsing-error-not-well-formed?rq=1&quot;&gt;http://stackoverflow.com/questions/4267244/xml-parsing-error-not-well-formed?rq=1&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/6871923978849230615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/xml-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6871923978849230615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6871923978849230615'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/xml-error.html' title='XML ERROR'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-4977917018587624908</id><published>2012-07-06T17:10:00.000+07:00</published><updated>2012-07-06T17:11:10.050+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>JAVA StringWriter</title><content type='html'>&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;boxinsidebg2&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; colspan=&quot;3&quot; height=&quot;60&quot; valign=&quot;top&quot; width=&quot;108%&quot;&gt;&lt;span class=&quot;f12b&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h1 style=&quot;font-family: inherit;&quot;&gt;
&lt;span class=&quot;f12b&quot;&gt;
&lt;span style=&quot;font-size: small;&quot;&gt;&lt;a href=&quot;http://www.codingdiary.com/developers/developers/diary/javaapi/java/io/SampleCode/StringWriterWriteExampleCode.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;http://www.codingdiary.com/developers/developers/diary/javaapi/java/io/SampleCode/StringWriterWriteExampleCode.html &lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h1&gt;
&lt;span class=&quot;f12b&quot;&gt;
&lt;h1&gt;

Java StringWriter write() Example&lt;/h1&gt;
&lt;/span&gt;
  &lt;span class=&quot;f12&quot;&gt;
    StringWriter class write() method example. This example shows you how to use write() method.
  &lt;/span&gt;
    &lt;span class=&quot;f12b&quot;&gt;
              

    &lt;/span&gt;
    &lt;br /&gt;
Syntax is : public void write(char[] cbuf, int off, int len)&lt;br /&gt;
This method writes a subArray of specified array to StringWriter buffer.
    &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;f12b&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;height: auto; overflow: auto; width: 685;&quot;&gt;
&lt;b&gt;Here is the code.&lt;br /&gt;
&lt;/b&gt;
&lt;br /&gt;
&lt;div align=&quot;left&quot; class=&quot;java&quot;&gt;
&lt;table bgcolor=&quot;#ffffff&quot; border=&quot;0&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;&gt;
    &lt;tbody&gt;
&lt;tr&gt;
            
            &lt;td align=&quot;left&quot; nowrap=&quot;nowrap&quot; valign=&quot;top&quot;&gt;&lt;code&gt; &lt;span style=&quot;color: #3f5fbf;&quot;&gt;/**&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;*&amp;nbsp;@(#)&amp;nbsp;WriteStringWriter.java&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;*&amp;nbsp;A&amp;nbsp;class&amp;nbsp;representing&amp;nbsp;use&amp;nbsp;of&amp;nbsp;method&amp;nbsp;write()&amp;nbsp;of&amp;nbsp;StringWriter&amp;nbsp;class&amp;nbsp;in&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;java.io&amp;nbsp;Package.&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;*&amp;nbsp;@Version&amp;nbsp;&amp;nbsp;29-May-2008&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;*&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f9fbf;&quot;&gt;@author&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;Rose&amp;nbsp;India&amp;nbsp;Team&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f5fbf;&quot;&gt;*/&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.io.*;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;WriteStringWriter&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;){&lt;/span&gt;&lt;br /&gt;
            &lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;char&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;arrChar&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[]&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;P&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;v&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;t&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;.&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;&amp;nbsp;&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;i&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;n&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;d&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;i&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;&#39;a&#39;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;Create&amp;nbsp;object&amp;nbsp;of&amp;nbsp;StringWriter&amp;nbsp;class&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StringWriter&amp;nbsp;obj&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StringWriter&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;append()&amp;nbsp;method&amp;nbsp;call.&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;obj.append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Rose&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;obj.append&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;India&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;String&amp;nbsp;in&amp;nbsp;string&amp;nbsp;buffer&amp;nbsp;is&amp;nbsp;:&amp;nbsp;&quot;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+&amp;nbsp;obj&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #3f7f5f;&quot;&gt;//&amp;nbsp;write()&amp;nbsp;method&amp;nbsp;call.&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;obj.write&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;arrChar,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;After&amp;nbsp;writing&amp;nbsp;a&amp;nbsp;sub&amp;nbsp;array&amp;nbsp;StringBuffer&amp;nbsp;is&amp;nbsp;:&amp;nbsp;&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;+obj&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
            &lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;/code&gt;         &lt;/td&gt;
            
        &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;f12b&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;height: auto; overflow: auto; width: 685;&quot;&gt;
&lt;span class=&quot;f12b&quot;&gt;&lt;b&gt;Output of the program.&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;table align=&quot;&quot; border=&quot;1&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; height=&quot;53&quot; style=&quot;width: 321px;&quot; summary=&quot;&quot;&gt;
    &lt;tbody&gt;
&lt;tr&gt;
            &lt;td&gt;String in string buffer is : Rose India&lt;br /&gt;
After writing a sub array StringBuffer is : Rose India Pvt.&lt;/td&gt;
        &lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;span class=&quot;f12b&quot;&gt;&lt;b&gt;
&lt;/b&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;f12b&quot;&gt;
&lt;/span&gt;
&lt;/td&gt;
   &lt;/tr&gt;
&lt;tr&gt;
  &lt;td align=&quot;left&quot; class=&quot;boxinsidebg&quot; colspan=&quot;3&quot; valign=&quot;top&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/4977917018587624908/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/httpwww.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4977917018587624908'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4977917018587624908'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/httpwww.html' title='JAVA StringWriter'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-8663381571255067967</id><published>2012-07-06T15:05:00.002+07:00</published><updated>2012-07-06T15:05:29.797+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>ARRAY LIST IN JAVA</title><content type='html'>&lt;br /&gt;
&lt;a href=&quot;http://www.java-samples.com/showtutorial.php?tutorialid=234&quot; target=&quot;_blank&quot;&gt;http://www.java-samples.com/showtutorial.php?tutorialid=234 &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;b&gt;ArrayList
&lt;/b&gt;class extends &lt;b&gt;AbstractList
&lt;/b&gt;and implements the &lt;b&gt;List
&lt;/b&gt;interface. &lt;b&gt;ArrayList
&lt;/b&gt;
supports dynamic arrays that can grow as needed. In Java,
standard arrays are of a fixed length. After arrays are created, they cannot grow or shrink,
which means that you must know in advance how many elements an array will hold. But,
sometimes, you may not know until run time precisely how large of an array you need. To
handle this situation, the collections framework defines &lt;b&gt;ArrayList&lt;/b&gt;.
In essence, an &lt;b&gt;ArrayList
&lt;/b&gt;is a variable-length array of object references. That is, an &lt;b&gt;ArrayList
&lt;/b&gt;can dynamically increase
or decrease in size. Array lists are created with an initial size. When this
size is exceeded, the collection is automatically enlarged. When objects are removed, the array
may be shrunk.&lt;br /&gt;


&lt;b&gt;
ArrayList &lt;/b&gt;has
the constructors shown here:
&lt;code&gt;
&lt;br /&gt;&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;ArrayList( )
&lt;br /&gt;ArrayList(Collection &lt;i&gt;c&lt;/i&gt;)
&lt;br /&gt;ArrayList(int &lt;i&gt;capacity&lt;/i&gt;)
&lt;/code&gt;&lt;br /&gt;

&lt;br /&gt;
The first constructor builds an empty array list. The second
constructor builds an array list that is initialized with the elements of the collection &lt;i&gt;c&lt;/i&gt;.
The third constructor builds an array list that has the specified initial &lt;i&gt;capacity&lt;/i&gt;.
The capacity is the size of the underlying array that is used to store the elements. The capacity grows
automatically as elements are added to an array list.&lt;br /&gt;

The following program shows a simple use of &lt;b&gt;ArrayList&lt;/b&gt;.
An array list is created, and then objects of type &lt;b&gt;String
&lt;/b&gt;are added to it. (Recall
that a quoted string is translated into a
&lt;b&gt;
String &lt;/b&gt;object.)
The list is then displayed. Some of the elements are removed and the list is displayed again.&lt;br /&gt;

&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;// Demonstrate ArrayList.
&lt;br /&gt;import java.util.*;
&lt;br /&gt;class ArrayListDemo {
&lt;br /&gt;public static void main(String args[]) {
&lt;br /&gt;// create an array list
&lt;br /&gt;ArrayList al = new ArrayList();
&lt;br /&gt;System.out.println(&quot;Initial size of al: &quot; +
&lt;br /&gt;al.size());
&lt;br /&gt;// add elements to the array list
&lt;br /&gt;al.add(&quot;C&quot;);
&lt;br /&gt;al.add(&quot;A&quot;);
&lt;br /&gt;al.add(&quot;E&quot;);
&lt;br /&gt;al.add(&quot;B&quot;);
&lt;br /&gt;al.add(&quot;D&quot;);
&lt;br /&gt;al.add(&quot;F&quot;);
&lt;br /&gt;al.add(1, &quot;A2&quot;);
&lt;br /&gt;System.out.println(&quot;Size of al after additions: &quot; +
&lt;br /&gt;al.size());
&lt;br /&gt;// display the array list
&lt;br /&gt;System.out.println(&quot;Contents of al: &quot; + al);
&lt;br /&gt;// Remove elements from the array list
&lt;br /&gt;al.remove(&quot;F&quot;);
&lt;br /&gt;al.remove(2);
&lt;br /&gt;System.out.println(&quot;Size of al after deletions: &quot; +
&lt;br /&gt;al.size());
&lt;br /&gt;System.out.println(&quot;Contents of al: &quot; + al);
&lt;br /&gt;}
&lt;br /&gt;}&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&lt;/code&gt;
&lt;br /&gt;
The output from this program is shown here:&lt;br /&gt;

&lt;code&gt;Initial size of al: 0
&lt;br /&gt;Size of al after additions: 7
&lt;br /&gt;Contents of al: [C, A2, A, E, B, D, F]
&lt;br /&gt;Size of al after deletions: 5
&lt;br /&gt;Contents of al: [C, A2, E, B, D]&lt;/code&gt;
Notice that &lt;b&gt;a1
&lt;/b&gt;starts out empty and
grows as elements are added to it. When elements are removed, its size is reduced.&lt;br /&gt;

Although the capacity of an &lt;b&gt;ArrayList
&lt;/b&gt;object increases
automatically as objects are stored in it, you can increase the capacity of an &lt;b&gt;ArrayList
&lt;/b&gt;object manually by
calling
&lt;b&gt;
ensureCapacity( )&lt;/b&gt;.
You might want to do this if you know in advance that you will be 
storing many more items in the collection that it can currently
hold. By increasing its capacity once, at the start, you can prevent 
several
reallocations later. Because reallocations are costly in terms of time, 
preventing
unnecessary ones improves performance. The signature for &lt;b&gt;ensureCapacity(
) &lt;/b&gt;is shown here:&lt;br /&gt;

void ensureCapacity(int &lt;i&gt;cap&lt;/i&gt;)&lt;br /&gt;

Here, &lt;i&gt;cap
&lt;/i&gt;is the new capacity. Conversely, if you want to reduce the size of the array that
underlies an &lt;b&gt;ArrayList
&lt;/b&gt;object so that it is precisely as large as the number of items that it
is currently holding, call
&lt;b&gt;
&lt;br /&gt;trimToSize( )&lt;/b&gt;,
shown here:&lt;br /&gt;

&lt;code&gt;void trimToSize( )&lt;/code&gt;

&lt;b&gt;
Obtaining an Array from an ArrayList
&lt;/b&gt;
&lt;br /&gt;

When working with &lt;b&gt;ArrayList&lt;/b&gt;,
you will sometimes want to obtain an actual array that contains the contents of the list. As explained earlier, you can
do this by calling &lt;b&gt;toArray( )&lt;/b&gt;.
Several reasons exist why you might want to convert a collection into an array
such as:&lt;br /&gt;

• To obtain faster processing times for certain operations.
&lt;br /&gt;• To pass an array to a method that is not overloaded to
accept a collection.
&lt;br /&gt;• To integrate your newer, collection-based code with legacy
code that does not understand collections.&lt;br /&gt;

Whatever the reason, converting an &lt;b&gt;ArrayList
&lt;/b&gt;to an array is a trivial
matter, as the following program shows:&lt;br /&gt;

&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;// get array
&lt;br /&gt;Object ia[] = al.toArray();
&lt;br /&gt;int sum = 0;
&lt;br /&gt;// sum the array
&lt;br /&gt;for(int i=0; i&amp;lt;ia.length; i++)
&lt;br /&gt;sum += ((Integer) ia[i]).intValue();
&lt;br /&gt;System.out.println(&quot;Sum is: &quot; + sum);
&lt;br /&gt;}
&lt;br /&gt;}&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&lt;/code&gt;
&lt;br /&gt;
The output from the program is shown here:
&lt;code&gt;
&lt;br /&gt;&amp;nbsp;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;Contents of al: [1, 2, 3, 4]
&lt;br /&gt;Sum is: 10&lt;/code&gt;
&lt;br /&gt;
&lt;br /&gt;
The program begins by creating a collection of integers. As
explained, you cannot store primitive types in a collection, so objects of type &lt;b&gt;Integer
&lt;/b&gt;are created and stored.
Next,
&lt;b&gt;
toArray( ) &lt;/b&gt;is
called and it obtains an array of &lt;b&gt;Object&lt;/b&gt;s.
The contents of this array are cast to &lt;b&gt;Integer&lt;/b&gt;,
and then the values are summed.</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/8663381571255067967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/array-list-in-java.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8663381571255067967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8663381571255067967'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/array-list-in-java.html' title='ARRAY LIST IN JAVA'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-6717036276960460030</id><published>2012-07-04T11:27:00.005+07:00</published><updated>2012-07-04T11:27:59.849+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>CONNECT SSH IN PHP</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html&quot; target=&quot;_blank&quot;&gt;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html &lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Secara
 default PHP tidak menyertakan library untuk melakukak SSH. Pada posting
 ini akan coba dijelasakan untuk melakukan Connection SSH melalui PHP.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Spesifikasi komputer pada posting ini adalah :&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Operating System Linux Ubuntu Lucid Lynx&lt;/li&gt;
&lt;li&gt;PHP version 5.3.2&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Agar PHP dapat melakukan SSH membutuhkan sebuah library. Library tersebut adalah &lt;a href=&quot;http://phpseclib.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;PHP Secure Communications Library&lt;/a&gt; atau biasa di singkat &lt;a href=&quot;http://phpseclib.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;phpseclib&lt;/a&gt; &lt;/div&gt;
&lt;a href=&quot;&quot; name=&quot;more&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;b&gt;phpseclib&lt;/b&gt; adalah sebuah library
 PHP untuk melakukan berbagai komunikasi melalui SSH, SFTP, Aritmatika 
Presisi dan berbagai macam Kriptografi. Berikut ini adalah cara 
menggunakan libary &lt;b&gt;phpseclib&lt;/b&gt; untuk SSH.&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Download library &lt;b&gt;phpseclib&lt;/b&gt; di &lt;a href=&quot;http://phpseclib.sourceforge.net/&quot; target=&quot;_blank&quot;&gt;http://phpseclib.sourceforge.net/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Ekstrak &lt;b&gt;phpseclib0.2.1a.zi&lt;/b&gt;p di &lt;b&gt;www root/public htm&lt;/b&gt;l web server Anda.&lt;/li&gt;
&lt;li&gt;Kemudian buat sebuah file pada folder hasil ekstrak&lt;b&gt; phpseclib0.2.1a.zip&lt;/b&gt; lalu sebagi contoh ketikan perintah seperti dibawah ini&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;dp-highlighter&quot;&gt;
&lt;div class=&quot;bar&quot;&gt;
&lt;div class=&quot;tools&quot;&gt;
&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;view plain&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;print&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;?&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;ol class=&quot;dp-c&quot; start=&quot;1&quot;&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;&amp;lt;?php&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;include&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;Net/SSH2.php&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;vars&quot;&gt;$ssh&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt;&lt;span&gt;&amp;nbsp;Net_SSH2(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;127.0.0.1&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt;&lt;span&gt;&amp;nbsp;(!&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ssh&lt;/span&gt;&lt;span&gt;-&amp;gt;login(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;dendie&#39;&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;xxx&#39;&lt;/span&gt;&lt;span&gt;))&amp;nbsp;{&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;func&quot;&gt;exit&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;Login&amp;nbsp;Failed&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$ssh&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;func&quot;&gt;exec&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;ls&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;?&amp;gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pada contoh diatas malakukan connection ssh ke komputer &lt;b&gt;127.0.0.1&lt;/b&gt; dengan username name &lt;b&gt;dendie&lt;/b&gt; dan password &lt;b&gt;xxx&lt;/b&gt; Dan &lt;b&gt;$ssh-&amp;gt;exec(&#39;pwd&#39;)&lt;/b&gt; adalah perintah command line linux untuk mendapatkan alamat path aktif berada. Hasil perintah di atas adalah sebagai berikut  &lt;/div&gt;
&lt;div class=&quot;dp-highlighter&quot;&gt;
&lt;div class=&quot;bar&quot;&gt;
&lt;div class=&quot;tools&quot;&gt;
&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;view plain&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;print&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;?&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;ol class=&quot;dp-c&quot; start=&quot;1&quot;&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span&gt;/home/dendie&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Sebagai Contoh dalam 
pengembangan selanjutnya Connection SSH melalui PHP dapat dikembangkan 
untuk melakukan monitoring kapasitas harddisk, CPU Usage, Memori Usage 
dsb, secara bersamaan dan secara remote kebanyak komputer/server, 
kemudian hasilnya ditampilkan pada web-page, seperti contoh dibawah ini:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;340&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-7BBSEzfh2PqzAJ22oEEhybl2Ga-27E-EYHFfgz_4n05rmZITkGzZq63BmB8nv-e4_5mwxZ-MSCCLKTmrnqBqRwUqsIR66Ni35TtHAygOfRcKfp-iD4UFpyRDApKiWd84yHHCbhbwejk/s400/Screenshot.png&quot; style=&quot;margin-left: auto; margin-right: auto;&quot; width=&quot;400&quot; /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
Untuk mempermudah melakukan monitoring serprti di atas dapat menggunakan class actServer, silakan download di &lt;a href=&quot;http://link.cari-info.com/actServer.zip&quot;&gt;klik download&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Berikut ini adalah cara menggunakan-nya:&lt;br /&gt;
&lt;div class=&quot;dp-highlighter&quot;&gt;
&lt;div class=&quot;bar&quot;&gt;
&lt;div class=&quot;tools&quot;&gt;
&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;view plain&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;print&lt;/a&gt;&lt;a href=&quot;http://dendieisme.blogspot.com/2010/09/connect-ssh-with-php.html#&quot;&gt;?&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;ol class=&quot;dp-c&quot; start=&quot;1&quot;&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;include&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;actServer.php&#39;&lt;/span&gt;&lt;span&gt;)&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;error_reporting&lt;/span&gt;&lt;span&gt;(0);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt;&lt;span&gt;&amp;nbsp;actServerClass();&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;setServer(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;127.0.0.1&#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;username&#39;&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;password&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;getCpuUsePer().&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;&amp;nbsp;%&#39;&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//CPU&amp;nbsp;Active&amp;nbsp;processes&amp;nbsp;dalam&amp;nbsp;persen&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;act-&amp;gt;getMemUsePer().&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;&amp;nbsp;%&#39;&lt;/span&gt;&lt;span&gt;;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//Memori&amp;nbsp;Active&amp;nbsp;processes&amp;nbsp;dalam&amp;nbsp;persen&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;getMemUse();&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//Memori&amp;nbsp;Usage&amp;nbsp;(megabyte)&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;getSpace();&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//Harddisk&amp;nbsp;Space&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;getDetail(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;mem&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//Detail&amp;nbsp;Active&amp;nbsp;processes&amp;nbsp;Memori&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;func&quot;&gt;echo&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;getDetail(&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&#39;cpu&#39;&lt;/span&gt;&lt;span&gt;);&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;//Detail&amp;nbsp;Active&amp;nbsp;processes&amp;nbsp;CPU&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;&quot;&gt;&lt;span&gt;&lt;span class=&quot;vars&quot;&gt;$act&lt;/span&gt;&lt;span&gt;-&amp;gt;setflush()&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;span class=&quot;post-author vcard&quot;&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/6717036276960460030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/connect-ssh-in-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6717036276960460030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6717036276960460030'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/connect-ssh-in-php.html' title='CONNECT SSH IN PHP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-7BBSEzfh2PqzAJ22oEEhybl2Ga-27E-EYHFfgz_4n05rmZITkGzZq63BmB8nv-e4_5mwxZ-MSCCLKTmrnqBqRwUqsIR66Ni35TtHAygOfRcKfp-iD4UFpyRDApKiWd84yHHCbhbwejk/s72-c/Screenshot.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5912755515967169827</id><published>2012-07-03T17:20:00.001+07:00</published><updated>2012-07-03T17:20:15.166+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LINUX"/><title type='text'>NGINX</title><content type='html'>http://blog.s13epy.web.id/instalasi-nginx.html&lt;br /&gt;
&lt;br /&gt;
Apa sih &lt;strong&gt;nginx&lt;/strong&gt;? Nginx adalah webserver sama seperti &lt;strong&gt;Apache&lt;/strong&gt; dan &lt;strong&gt;Lighttpd&lt;/strong&gt;, mungkin bedanya seperti yang saya cari di paman &lt;a href=&quot;http://google.co.id/&quot;&gt;google&lt;/a&gt;,  klo nginx banyak yang bilang lebih powerfull n lebih cepet, dibandingkan  dengan Apache ataupun Lighttpd.
&lt;br /&gt;
Disini saya akan melakukan instalasi Nginx di LinuxMint 8 (Helena)  yang merupakan turunan dari ubuntu 9.10 (Karmic Koala).&lt;br /&gt;

Yang pertama kita Instalasi Nginx terlebih dahulu&lt;br /&gt;

&lt;blockquote&gt;
sudo apt-get install nginx&lt;/blockquote&gt;
&lt;span id=&quot;more-17&quot;&gt;&lt;/span&gt;atau bila kita ingin menggunakan source code&lt;br /&gt;

&lt;blockquote&gt;
sudo wget http://sysoev.ru/nginx/nginx-0.6.36.tar.gz&lt;br /&gt;
tar -xzvf nginx-0.6.36.tar.gz&lt;br /&gt;
cd nginx-0.6.36.tar.gz&lt;br /&gt;
sudo apt-get install build-essential&lt;br /&gt;
./configure&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;/blockquote&gt;
untuk settingan di ubuntu ataupun turunannya&lt;br /&gt;

&lt;blockquote&gt;
./configure –conf-path=/etc/nginx/nginx.conf \&lt;br /&gt;
–error-log-path=/var/log/nginx/error.log –pid-path=/var/run/nginx.pid \&lt;br /&gt;
–lock-path=/var/lock/nginx.lock    –http-log-path=/var/log/nginx/access.log \&lt;br /&gt;
–http-client-body-temp-path=/var/lib/nginx/body  –http-proxy-temp-path=/var/lib/nginx/proxy \&lt;br /&gt;
–http-fastcgi-temp-path=/var/lib/nginx/fastcgi –with-debug  –with-http_stub_status_module \&lt;br /&gt;
–with-http_flv_module –with-http_ssl_module –with-http_dav_module&lt;br /&gt;
make&lt;br /&gt;
sudo make install&lt;/blockquote&gt;
Setelah itu jalankan nginx&lt;br /&gt;

&lt;blockquote&gt;
sudo  /etc/init.d/nginx start&lt;/blockquote&gt;
Agar setiap booting nginx dapat langsung berjalan&lt;br /&gt;

&lt;blockquote&gt;
sudo  update-rc.d nginx defaults&lt;/blockquote&gt;
Untuk melihat  apakah nginx telah berjalan ketikkan &lt;strong&gt;localhost&lt;/strong&gt; pada browser.&lt;br /&gt;

Selanjutnya kita install paket php&lt;br /&gt;

&lt;blockquote&gt;
sudo apt-get install php5-cgi php5-mysql php5-curl  
php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt  
php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp  
php5-sqlite php5-tidy php5-xmlrpc php5-xsl&lt;br /&gt;
kemudian edit file &lt;strong&gt;/etc/php5/cgi/php.ini&lt;/strong&gt;&lt;br /&gt;
sudo gedit /etc/php5/cgi/php.ini&lt;/blockquote&gt;
Ubah &lt;strong&gt;cgi.fix_pathinfo = 0&lt;/strong&gt; menjadi 1&lt;br /&gt;

&lt;blockquote&gt;
[...]&lt;br /&gt;
cgi.fix_pathinfo = 1&lt;/blockquote&gt;
Kemudian install&lt;br /&gt;

&lt;blockquote&gt;
sudo apt-get install spawn-fcgi&lt;/blockquote&gt;
gunakan perintah berikut untuk menjalankan php cgi&lt;br /&gt;

&lt;blockquote&gt;
sudo /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data  -g www-data -f /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid&lt;/blockquote&gt;
tambahkan perintah di pada &lt;strong&gt;/etc/rc.local&lt;/strong&gt;&lt;br /&gt;

&lt;blockquote&gt;
[...]&lt;br /&gt;
/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -u www-data -g www-data -f  /usr/bin/php5-cgi -P /var/run/fastcgi-php.pid&lt;br /&gt;
[...]&lt;/blockquote&gt;
edit file &lt;strong&gt;nginx.conf&lt;/strong&gt;&lt;br /&gt;

&lt;blockquote&gt;

sudo gedit /etc/nginx/nginx.conf
&lt;/blockquote&gt;
edit bagian berikut&lt;br /&gt;

&lt;blockquote&gt;
[...]&lt;br /&gt;
worker_processes  5;&lt;br /&gt;
[...]&lt;br /&gt;
keepalive_timeout   2;&lt;br /&gt;
[...]&lt;/blockquote&gt;
Selajutnya mengubah path file default sesuai keinginan kita&lt;br /&gt;

&lt;blockquote&gt;

sudo gedit /etc/nginx/sites-available/default
&lt;/blockquote&gt;
&lt;blockquote&gt;
[...]&lt;br /&gt;
server {&lt;br /&gt;
listen   80;&lt;br /&gt;
server_name  localhost;&lt;/blockquote&gt;
&lt;blockquote&gt;
access_log  /var/log/nginx/localhost.access.log;&lt;/blockquote&gt;
&lt;blockquote&gt;
location / {&lt;br /&gt;
#root   /var/www/nginx-default;&lt;br /&gt;
root /home/vq/public_html;&lt;br /&gt;
index  index.php index.html index.htm;&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;blockquote&gt;
location /doc {&lt;br /&gt;
root   /usr/share;&lt;br /&gt;
autoindex on;&lt;br /&gt;
allow 127.0.0.1;&lt;br /&gt;
deny all;&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;blockquote&gt;
location /images {&lt;br /&gt;
root   /usr/share;&lt;br /&gt;
autoindex on;&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;blockquote&gt;
#error_page  404  /404.html;&lt;/blockquote&gt;
&lt;blockquote&gt;
# redirect server error pages to the static page  /50x.html&lt;br /&gt;
#&lt;br /&gt;
error_page   500 502 503 504  /50x.html;&lt;br /&gt;
location = /50x.html {&lt;br /&gt;
#root   /var/www/nginx-default;&lt;br /&gt;
root /home/vq/public_html;&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;blockquote&gt;
# proxy the PHP scripts to Apache listening on  127.0.0.1:80&lt;br /&gt;
#&lt;br /&gt;
#location ~ \.php$ {&lt;br /&gt;
#proxy_pass   http://127.0.0.1;&lt;br /&gt;
#}&lt;/blockquote&gt;
&lt;blockquote&gt;
# pass the PHP scripts to FastCGI server listening on  127.0.0.1:9000&lt;br /&gt;
#&lt;br /&gt;
location ~ \.php$ {&lt;br /&gt;
fastcgi_pass   127.0.0.1:9000;&lt;br /&gt;
fastcgi_index  index.php;&lt;br /&gt;
fastcgi_param  SCRIPT_FILENAME   /home/vq/public_html$fastcgi_script_name;&lt;br /&gt;
include               fastcgi_params;&lt;br /&gt;
}&lt;/blockquote&gt;
&lt;blockquote&gt;
# deny access to .htaccess files, if Apache’s document  root&lt;br /&gt;
# concurs with nginx’s one&lt;br /&gt;
#&lt;br /&gt;
location ~ /\.ht {&lt;br /&gt;
deny  all;&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
[...]&lt;/blockquote&gt;
Terakhir kita tinggal melakukan restart nginx&lt;br /&gt;

&lt;blockquote&gt;
sudo /etc/init.d/nginx restart&lt;/blockquote&gt;
Untuk melihat apakah php-nya sudah berjalan&lt;br /&gt;

&lt;blockquote&gt;
sudo  gedit /home/vq/public_html/info.php&lt;/blockquote&gt;
isi file  info.php dengan kode berikut</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5912755515967169827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/nginx.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5912755515967169827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5912755515967169827'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/nginx.html' title='NGINX'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-4023047260894060014</id><published>2012-07-01T03:35:00.003+07:00</published><updated>2012-07-01T03:35:59.840+07:00</updated><title type='text'>Login Logout CodeIgniter</title><content type='html'>&lt;a href=&quot;http://www.codefactorycr.com/login-with-codeigniter-php.html&quot;&gt;http://www.codefactorycr.com/login-with-codeigniter-php.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;



  
    
    &lt;br /&gt;
&lt;h1&gt;
&lt;a href=&quot;http://www.codefactorycr.com/login-with-codeigniter-php.html&quot;&gt;Simple Login with CodeIgniter in PHP&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;meta&quot;&gt;

       Apr 18, 2011 &amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp; by &lt;span class=&quot;author&quot;&gt;aarias&lt;/span&gt; &amp;nbsp;&amp;nbsp;//&amp;nbsp;&amp;nbsp;  &lt;a href=&quot;http://www.codefactorycr.com/blog&quot; rel=&quot;category tag&quot; title=&quot;View all posts in Blog&quot;&gt;Blog&lt;/a&gt;, &lt;a href=&quot;http://www.codefactorycr.com/blog/php&quot; rel=&quot;category tag&quot; title=&quot;View all posts in PHP&quot;&gt;PHP&lt;/a&gt;  &amp;nbsp;//&amp;nbsp;  &lt;a href=&quot;http://www.codefactorycr.com/login-with-codeigniter-php.html#respond&quot; title=&quot;Comment on Simple Login with CodeIgniter in PHP&quot;&gt;No Comments&lt;/a&gt; 
      &lt;/div&gt;
&lt;a href=&quot;http://codeigniter.com/&quot;&gt;&lt;img alt=&quot;Code Igniter logo&quot; class=&quot;alignleft size-full wp-image-213&quot; height=&quot;48&quot; src=&quot;http://www.codefactorycr.com/wp-content/uploads/2011/04/codeigniter.png&quot; title=&quot;codeigniter&quot; width=&quot;48&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;http://codeigniter.com/&quot; title=&quot;Code Igniter&quot;&gt;CodeIgniter&lt;/a&gt;
 is an open source Web Application framework built in PHP designed to 
make your life as a programmer easier, while allowing you good speed for
 development, and also good performance when the site is up and running.&lt;br /&gt;

&lt;span id=&quot;more-206&quot;&gt;&lt;/span&gt;Being a Java developer for almost 10 years now, when I had to move to PHP I chose CodeIgniter for the following reasons:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;Easy to install and configure (being a newbie in PHP this was crucial)&lt;/li&gt;
&lt;li&gt;Clean and elegant &lt;a href=&quot;http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller&quot; target=&quot;_blank&quot; title=&quot;Model View Controller&quot;&gt;MVC&lt;/a&gt; implementation&lt;/li&gt;
&lt;li&gt;Uses &lt;a href=&quot;http://en.wikipedia.org/wiki/Active_record_pattern&quot; target=&quot;_blank&quot; title=&quot;Active Record Patter&quot;&gt;Active Record&lt;/a&gt; pattern for database access&lt;/li&gt;
&lt;li&gt;Overall small footprint and good performance&lt;/li&gt;
&lt;/ul&gt;
Usually when you are building a program, the login/logout 
functionality is a must we always have to go through, so this quick 
tutorial will focus on this functionality, taking advantage of the 
benefits of using CodeIgniter instead of doing it from scratch in PHP.&lt;br /&gt;

&lt;h2&gt;
Requirements&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://codeigniter.com/downloads/&quot; target=&quot;_blank&quot; title=&quot;CodeIgniter downloads&quot;&gt;CodeIgniter&lt;/a&gt; framework.&amp;nbsp; By the time this tutorial was done, the latest version was &lt;strong&gt;2.0.2&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Any Apache/PHP/MySQL stack.&amp;nbsp; You can install the applications 
independently, or install one of those packages that have all of them 
bundled together.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
Installing CodeIgniter&lt;/h2&gt;
To install CodeIgniter, you only need to uncompress the Zip file you download from the site into your &lt;strong&gt;htdocs&lt;/strong&gt; directory and you’re good to go.&amp;nbsp; We’ll configure the database access later.&lt;br /&gt;

&lt;h2&gt;
Create the database&lt;/h2&gt;
For this tutorial, you need a MySQL database with the following table:&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_448813&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;keyword&quot;&gt;CREATE&lt;/code&gt; &lt;code class=&quot;keyword&quot;&gt;TABLE&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;`users` (&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;`id` tinyint(4) &lt;/code&gt;&lt;code class=&quot;color1&quot;&gt;NOT&lt;/code&gt; &lt;code class=&quot;color1&quot;&gt;NULL&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;AUTO_INCREMENT,&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;`username` &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;varchar&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(10) &lt;/code&gt;&lt;code class=&quot;color1&quot;&gt;NOT&lt;/code&gt; &lt;code class=&quot;color1&quot;&gt;NULL&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;,&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;`&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;` &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;varchar&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(100) &lt;/code&gt;&lt;code class=&quot;color1&quot;&gt;NOT&lt;/code&gt; &lt;code class=&quot;color1&quot;&gt;NULL&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;,&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;PRIMARY&lt;/code&gt; &lt;code class=&quot;keyword&quot;&gt;KEY&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;(`id`)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;) ENGINE=MyISAM &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;DEFAULT&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;CHARSET=latin1 AUTO_INCREMENT=1 ;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
Remember also to add at least one user.&amp;nbsp; We’ll add one user called &lt;strong&gt;bob &lt;/strong&gt;with password &lt;strong&gt;supersecret&lt;/strong&gt;.&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_917477&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;keyword&quot;&gt;insert&lt;/code&gt; &lt;code class=&quot;keyword&quot;&gt;into&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;users (username, &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;) &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;values&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;bob&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, MD5(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;supersecret&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;));&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;
Configure CodeIgniter&lt;/h2&gt;
&lt;h3&gt;
Database Access&lt;/h3&gt;
Update the file &lt;strong&gt;application/config/database.php&lt;/strong&gt; in your CodeIgniter installation with your database info:&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_232775&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;44&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$db&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;default&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;][&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;hostname&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;localhost&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;45&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$db&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;default&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;][&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;yourdbusername&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;46&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$db&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;default&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;][&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;password&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;yourdbpassword&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;47&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$db&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;default&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;][&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;database&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;yourdbname&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;
Default Controller&lt;/h3&gt;
We need to tell CodeIgniter to land into our login page instead of the default welcome page.&amp;nbsp; Update the file&amp;nbsp;&lt;strong&gt;application/config/routes.php &lt;/strong&gt;in your CodeIgniter installation with you controller’s name.&amp;nbsp; We’ll call our landing controller &lt;strong&gt;login&lt;/strong&gt;.&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_457930&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;41&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$route&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;default_controller&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&quot;login&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;
Default Libraries&lt;/h3&gt;
In the file &lt;strong&gt;application/config/autoload.php &lt;/strong&gt; you can
 configure the default libraries you want to load in all your 
controllers.&amp;nbsp; For our case, we’ll load the database and session 
libraries, since we want to handle user sessions, and also the URL 
helper for internal link generation&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_695501&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;55&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$autoload&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;libraries&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;database&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;,&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;session&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_125918&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;67&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$autoload&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;helper&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;url&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;
Encryption Key&lt;/h3&gt;
When you use the &lt;strong&gt;session&lt;/strong&gt; library, you need to set the &lt;strong&gt;encryption_key&lt;/strong&gt; in the file &lt;strong&gt;application/config/config.php&lt;/strong&gt;.&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_513449&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;227&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;variable&quot;&gt;$config&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;encryption_key&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;REALLY_LONG_NUMBER&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;
The Code&lt;/h3&gt;
Here are the actual Views, Controllers and Model we are using for the login functionality.&lt;br /&gt;

&lt;h4&gt;
User Model (application/models/user/php)&lt;/h4&gt;
&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_787941&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;Class User &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;extends&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;CI_Model&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;login(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$username&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; select(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;id, username, password&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; from(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;users&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; where(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username = &#39;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;. &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&quot;&#39;&quot;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;. &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$username&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;. &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&quot;&#39;&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; where(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;password = &#39;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;. &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&quot;&#39;&quot;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;. MD5(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;) . &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&quot;&#39;&quot;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; limit(1);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$query&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; db -&amp;gt; get();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$query&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;-&amp;gt; num_rows() == 1)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;variable&quot;&gt;$query&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;result();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;else&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;19&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;20&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;false;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;21&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;22&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;23&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;24&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Login Controller (application/controllers/login.php)&lt;/h4&gt;
&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_520673&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;&amp;lt;?php &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;( ! defined(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;BASEPATH&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)) &lt;/code&gt;&lt;code class=&quot;functions&quot;&gt;exit&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;No direct script access allowed&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;keyword&quot;&gt;class&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;Login &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;extends&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;CI_Controller {&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;__construct()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;parent::__construct();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;index()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;helper(&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;form&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;url&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;));&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;view(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;login_view&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Login View (application/views/login_view.php)&lt;/h4&gt;
&lt;div class=&quot;syntaxhighlighter  htmlscript&quot; id=&quot;highlighter_751807&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;&lt;a href=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&lt;/a&gt;&quot;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;html&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;xmlns&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;&lt;a href=&quot;http://www.w3.org/1999/xhtml&quot;&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;head&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;title&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Simple Login with CodeIgniter&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;title&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;head&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;body&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h1&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Simple Login with CodeIgniter&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h1&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;&amp;lt;?&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;php&lt;/code&gt; &lt;code class=&quot;htmlscript functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;htmlscript plain&quot;&gt;validation_errors(); &lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;&amp;lt;?&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;php&lt;/code&gt; &lt;code class=&quot;htmlscript functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;htmlscript plain&quot;&gt;form_open(&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&#39;verifylogin&#39;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;); &lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;label&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;username&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Username:&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;label&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;input&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;type&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;text&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;size&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;20&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;id&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;username&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;username&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;br&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;label&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;for&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;password&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Password:&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;label&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;input&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;type&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;password&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;size&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;20&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;id&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;passowrd&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;name&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;password&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;br&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;input&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;type&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;submit&quot;&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;value&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;Login&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;form&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;body&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;19&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;html&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
VerifyLogin Controller (application/controllers/verifylogin.php)&lt;/h4&gt;
This controller does the actual validation of the fields and checks the credentials against the database.&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_360709&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;&amp;lt;?php &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;( ! defined(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;BASEPATH&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)) &lt;/code&gt;&lt;code class=&quot;functions&quot;&gt;exit&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;No direct script access allowed&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;keyword&quot;&gt;class&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;VerifyLogin &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;extends&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;CI_Controller {&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;__construct()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;parent::__construct();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;model(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;user&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;,&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;,TRUE);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;index()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//This method will have the credentials validation&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;library(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;form_validation&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;form_validation-&amp;gt;set_rules(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;Username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;trim|required|xss_clean&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;form_validation-&amp;gt;set_rules(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;password&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;Password&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;trim|required|xss_clean|callback_check_database&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;19&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;form_validation-&amp;gt;run() == FALSE)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;20&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;21&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//Field validation failed.&amp;nbsp; User redirected to login page&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;22&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;view(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;login_view&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;23&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;24&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;else&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;25&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;26&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//Go to private area&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;27&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;redirect(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;home&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;refresh&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;28&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;29&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;30&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;31&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;32&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;check_database(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;33&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;34&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//Field validation succeeded.&amp;nbsp; Validate against database&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;35&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$username&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;input-&amp;gt;post(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;36&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;37&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//query the database&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;38&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$result&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;user-&amp;gt;login(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$username&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$password&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;39&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;40&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$result&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;41&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;42&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$sess_array&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;43&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$result&lt;/code&gt; &lt;code class=&quot;keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;variable&quot;&gt;$row&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;44&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;45&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$sess_array&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;46&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;id&#39;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;=&amp;gt; &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$row&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;id,&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;47&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;=&amp;gt; &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$row&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;username&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;48&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;49&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;session-&amp;gt;set_userdata(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;logged_in&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$sess_array&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;50&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;51&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;TRUE;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;52&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;53&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;else&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;54&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;55&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;form_validation-&amp;gt;set_message(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;check_database&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;Invalid username or password&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;56&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;return&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;false;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;57&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;58&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;59&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;60&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Home Controller (application/controllers/home.php)&lt;/h4&gt;
This is the private page (only authenticated users can access it).&lt;br /&gt;

&lt;div class=&quot;syntaxhighlighter  &quot; id=&quot;highlighter_241987&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;&amp;lt;?php &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;( ! defined(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;BASEPATH&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;)) &lt;/code&gt;&lt;code class=&quot;functions&quot;&gt;exit&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;No direct script access allowed&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;session_start(); &lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//we need to call PHP&#39;s session object to access it through CI&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;keyword&quot;&gt;class&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;Home &lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;extends&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;CI_Controller {&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;__construct()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;parent::__construct();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;index()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;12&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;session-&amp;gt;userdata(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;logged_in&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;))&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;13&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;14&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$session_data&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;session-&amp;gt;userdata(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;logged_in&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;15&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$data&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;] = &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$session_data&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;[&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;username&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;];&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;16&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;load-&amp;gt;view(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;home_view&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$data&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;17&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;18&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;else&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;19&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;20&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;comments&quot;&gt;//If no session, redirect to login page&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;21&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;redirect(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;login&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;refresh&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;22&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;23&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;24&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;25&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;keyword&quot;&gt;function&lt;/code&gt; &lt;code class=&quot;plain&quot;&gt;logout()&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;26&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;{&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;27&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;variable&quot;&gt;$this&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;-&amp;gt;session-&amp;gt;unset_userdata(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;logged_in&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;28&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;session_destroy();&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;29&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;redirect(&lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;home&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;string&quot;&gt;&#39;refresh&#39;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;);&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;30&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;31&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;32&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;}&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;33&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;34&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Home Page View (application/views/home_view.php)&lt;/h4&gt;
&lt;div class=&quot;syntaxhighlighter  htmlscript&quot; id=&quot;highlighter_241716&quot;&gt;
&lt;div class=&quot;lines&quot;&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;1&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;&lt;a href=&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&lt;/a&gt;&quot;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;2&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;html&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;xmlns&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;&lt;a href=&quot;http://www.w3.org/1999/xhtml&quot;&gt;http://www.w3.org/1999/xhtml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;3&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;head&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;4&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;title&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Simple Login with CodeIgniter - Private Area&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;title&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;5&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;head&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;6&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;body&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;7&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h1&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Home&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h1&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;8&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h2&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Welcome &lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;&amp;lt;?&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;php&lt;/code&gt; &lt;code class=&quot;htmlscript functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;htmlscript variable&quot;&gt;$username&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;; &lt;/code&gt;&lt;code class=&quot;htmlscript script&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;!&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;h2&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;9&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;a&lt;/code&gt; &lt;code class=&quot;htmlscript color1&quot;&gt;href&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;=&lt;/code&gt;&lt;code class=&quot;htmlscript string&quot;&gt;&quot;home/logout&quot;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;Logout&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;a&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt2&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;10&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;spaces&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;body&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div class=&quot;line alt1&quot;&gt;
&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;number&quot;&gt;&lt;code&gt;11&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;lt;/&lt;/code&gt;&lt;code class=&quot;htmlscript keyword&quot;&gt;html&lt;/code&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;&lt;td class=&quot;content&quot;&gt;&lt;code class=&quot;htmlscript plain&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
The code is pretty easy to follow and understand.&amp;nbsp; Also, &lt;a href=&quot;http://files.codefactorycr.com/blog/codeigniter_login.tar.gz&quot; title=&quot;Download code here&quot;&gt;you can download the code from here&lt;/a&gt;,
 so you can install it and test it in your location.&amp;nbsp; You’ll only need a
 full installation of CodeIgniter 2.0.2 and the table in your MySQL 
database.&amp;nbsp; If you need any help, feel free to leave us a comment or 
shoot us an email.&lt;br /&gt;

Also, this code uses a pretty basic form validation from CodeIgniter.&amp;nbsp; If you need a more complex validation process, check &lt;a href=&quot;http://codeigniter.com/user_guide/libraries/form_validation.html&quot; target=&quot;_blank&quot; title=&quot;CodeIgniter Form Validation&quot;&gt;CodeIgniter’s Form Validation&lt;/a&gt; docs at their site.</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/4023047260894060014/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/07/login-logout-codeigniter.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4023047260894060014'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4023047260894060014'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/07/login-logout-codeigniter.html' title='Login Logout CodeIgniter'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5062859587231189454</id><published>2012-06-28T11:53:00.001+07:00</published><updated>2012-06-28T11:53:18.128+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="LINUX"/><title type='text'>REMOVE FILE OR DIRECTORY FROM CONSOLE LINUX</title><content type='html'>&lt;br /&gt;
Use the rmdir command. This command remove the DIRECTORY(ies), if 
they are empty. Open a command-line terminal (select Applications &amp;gt; 
Accessories &amp;gt; Terminal), and then type the following command to 
remove a directory called  /tmp/docs:&lt;br /&gt;
&lt;pre class=&quot;bash&quot;&gt;&amp;nbsp;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;rmdir&lt;/span&gt; /tmp/docs
&amp;nbsp;&lt;/pre&gt;
If a directory is not empty you will get an error:&lt;br /&gt; &lt;code&gt;$ rmdir letters&lt;/code&gt;&lt;br /&gt; Output:&lt;br /&gt;
&lt;pre&gt;rmdir: letters: Directory not empty&lt;/pre&gt;
You can cd to the directory to find out files:&lt;br /&gt; &lt;code&gt;$ cd letters&lt;br /&gt; $ ls&lt;/code&gt;&lt;br /&gt;
&lt;h2&gt;
Linux Remove Entire Directory Command&lt;/h2&gt;
To
 remove all directories and subdirectories use rm command. For example 
remove letters and all subdirectories and files inside this directory, 
type the following command (&lt;strong&gt;&lt;span style=&quot;color: red;&quot;&gt;warning&lt;/span&gt;&lt;/strong&gt; all files including subdirectories will be deleted permanently):&lt;br /&gt; &lt;code&gt;$ rm -rf letters/&lt;/code&gt;&lt;br /&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5062859587231189454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/remove-file-or-directory-from-console.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5062859587231189454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5062859587231189454'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/remove-file-or-directory-from-console.html' title='REMOVE FILE OR DIRECTORY FROM CONSOLE LINUX'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-2958509296613198752</id><published>2012-06-27T16:11:00.002+07:00</published><updated>2012-06-27T16:11:39.509+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>JAVA TRANSFORM XML FILE FROM SQL</title><content type='html'>&lt;a href=&quot;http://www.java2s.com/Code/Java/Database-SQL-JDBC/ConvertaResultSettoXML.htm&quot;&gt;http://www.java2s.com/Code/Java/Database-SQL-JDBC/ConvertaResultSettoXML.htm&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.io.StringWriter;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.sql.Connection;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.sql.DriverManager;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.sql.ResultSet;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;java.sql.ResultSetMetaData;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.parsers.DocumentBuilder;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.parsers.DocumentBuilderFactory;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.transform.OutputKeys;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.transform.Transformer;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.transform.TransformerFactory;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.transform.dom.DOMSource;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;javax.xml.transform.stream.StreamResult;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.w3c.dom.Document;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;import&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;org.w3c.dom.Element;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;class&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Main&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;public&amp;nbsp;static&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;void&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;main&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;args&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;[])&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;throws&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Exception&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;DocumentBuilderFactory&amp;nbsp;factory&amp;nbsp;=&amp;nbsp;DocumentBuilderFactory.newInstance&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;DocumentBuilder&amp;nbsp;builder&amp;nbsp;=&amp;nbsp;factory.newDocumentBuilder&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Document&amp;nbsp;doc&amp;nbsp;=&amp;nbsp;builder.newDocument&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Element&amp;nbsp;results&amp;nbsp;=&amp;nbsp;doc.createElement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Results&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc.appendChild&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;results&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;Class&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.forName&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;sun.jdbc.odbc.JdbcOdbcDriver&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Connection&amp;nbsp;con&amp;nbsp;=&amp;nbsp;DriverManager&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.getConnection&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;jdbc:odbc:Driver={Microsoft&amp;nbsp;Access&amp;nbsp;Driver&amp;nbsp;(*.mdb)};DBQ=c:/access.mdb&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ResultSet&amp;nbsp;rs&amp;nbsp;=&amp;nbsp;con.createStatement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.executeQuery&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;select&amp;nbsp;*&amp;nbsp;from&amp;nbsp;product&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;ResultSetMetaData&amp;nbsp;rsmd&amp;nbsp;=&amp;nbsp;rs.getMetaData&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;colCount&amp;nbsp;=&amp;nbsp;rsmd.getColumnCount&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;while&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rs.next&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Element&amp;nbsp;row&amp;nbsp;=&amp;nbsp;doc.createElement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;Row&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;results.appendChild&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;row&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;for&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;int&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&amp;nbsp;i&amp;nbsp;&amp;lt;=&amp;nbsp;colCount;&amp;nbsp;i++&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;String&amp;nbsp;columnName&amp;nbsp;=&amp;nbsp;rsmd.getColumnName&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Object&amp;nbsp;value&amp;nbsp;=&amp;nbsp;rs.getObject&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;i&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Element&amp;nbsp;node&amp;nbsp;=&amp;nbsp;doc.createElement&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;columnName&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node.appendChild&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc.createTextNode&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;value.toString&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()))&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;row.appendChild&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;node&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;DOMSource&amp;nbsp;domSource&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;DOMSource&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;doc&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;TransformerFactory&amp;nbsp;tf&amp;nbsp;=&amp;nbsp;TransformerFactory.newInstance&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Transformer&amp;nbsp;transformer&amp;nbsp;=&amp;nbsp;tf.newTransformer&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transformer.setOutputProperty&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;OutputKeys.OMIT_XML_DECLARATION,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;yes&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transformer.setOutputProperty&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;OutputKeys.METHOD,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;xml&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transformer.setOutputProperty&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;OutputKeys.ENCODING,&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #2a00ff;&quot;&gt;&quot;ISO-8859-1&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StringWriter&amp;nbsp;sw&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StringWriter&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StreamResult&amp;nbsp;sr&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #7f0055;&quot;&gt;&lt;b&gt;new&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;StreamResult&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;sw&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;transformer.transform&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;domSource,&amp;nbsp;sr&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;)&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;System.out.println&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;sw.toString&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;())&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;con.close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;rs.close&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;()&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: white;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/2958509296613198752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/java-transform-xml-file-from-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/2958509296613198752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/2958509296613198752'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/java-transform-xml-file-from-sql.html' title='JAVA TRANSFORM XML FILE FROM SQL'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-3323930063968297277</id><published>2012-06-22T16:03:00.002+07:00</published><updated>2012-06-22T16:03:23.968+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CUSTOM ROM ANDROID"/><title type='text'>GALAXYICS CAMERA</title><content type='html'>http://maclaw.pl/?p=51&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;IT ISN’T PATCH MADE BY LAGLOOSE, IT’S MADE BY MY TEAM AND WE CAN RELEASE IT WHEN WE WANT!&lt;/strong&gt;&lt;br /&gt;

&lt;strong&gt;&lt;/strong&gt;Preview isn’t working, but everything else (like flash etc.) is working normally:&lt;br /&gt;

&lt;a href=&quot;https://www.box.com/s/43b3687fbeda1155fd65&quot;&gt;https://www.box.com/s/43b3687fbeda1155fd65&lt;/a&gt;&lt;br /&gt;

(Just apply in recovery)&lt;br /&gt;

If you must to share that patch, link not directly to them, but to this post.&lt;br /&gt;

Mirrors aren’t welcomed.&lt;br /&gt;

Enjoy &lt;img alt=&quot;:D&quot; class=&quot;wp-smiley&quot; src=&quot;http://maclaw.pl/wp-includes/images/smilies/icon_biggrin.gif&quot; /&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/3323930063968297277/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/galaxyics-camera.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3323930063968297277'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3323930063968297277'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/galaxyics-camera.html' title='GALAXYICS CAMERA'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-3322820876265643339</id><published>2012-06-21T03:09:00.004+07:00</published><updated>2012-06-21T03:09:49.194+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse Ant"/><title type='text'>Copy Ant</title><content type='html'>&lt;h2&gt;
&lt;a href=&quot;&quot; name=&quot;copy&quot;&gt;Copy&lt;/a&gt;&lt;/h2&gt;
&lt;h3&gt;
Description&lt;/h3&gt;
Copies a file or resource collection to a new file or directory.  By default, files are
only copied if the source file is newer than the destination file,
or when the destination file does not exist.  However, you can explicitly
overwrite files with the &lt;code&gt;overwrite&lt;/code&gt; attribute.&lt;br /&gt;


&lt;a href=&quot;http://ant.apache.org/manual/Types/resources.html#collection&quot;&gt;Resource
Collection&lt;/a&gt;s are used to select a group of files to copy.  To use a
resource collection, the &lt;code&gt;todir&lt;/code&gt; attribute must be set.
&lt;strong&gt;Note&lt;/strong&gt; that some resources (for example
the &lt;a href=&quot;http://ant.apache.org/manual/Types/resources.html#file&quot;&gt;file&lt;/a&gt; resource)
return absolute paths as names and the result of using them without
using a nested mapper (or the flatten attribute) may not be what you
expect.&lt;br /&gt;



&lt;strong&gt;Note: &lt;/strong&gt;If you employ filters in your copy operation,
you should limit the copy to text files. Binary files will be corrupted
by the copy operation.
This applies whether the filters are implicitly defined by the
&lt;a href=&quot;http://ant.apache.org/manual/Tasks/filter.html&quot;&gt;filter&lt;/a&gt; task or explicitly provided to the copy
operation as &lt;a href=&quot;http://ant.apache.org/manual/Types/filterset.html&quot;&gt;filtersets&lt;/a&gt;.
  &lt;em&gt;See &lt;a href=&quot;http://ant.apache.org/manual/Tasks/copy.html#encoding&quot;&gt;encoding note&lt;/a&gt;&lt;/em&gt;.
&lt;br /&gt;

&lt;h3&gt;
Parameters&lt;/h3&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;&lt;b&gt;Attribute&lt;/b&gt;&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;&lt;b&gt;Required&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;file&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The file to copy.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;Yes, unless a nested
    resource collection element is used.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;preservelastmodified&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Give the copied files the same last modified
      time as the original source files.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;tofile&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The file to copy to.&lt;/td&gt;
    &lt;td align=&quot;center&quot; rowspan=&quot;2&quot; valign=&quot;top&quot;&gt;With the &lt;code&gt;file&lt;/code&gt;
      attribute, either &lt;code&gt;tofile&lt;/code&gt; or &lt;code&gt;todir&lt;/code&gt; can be used.&lt;br /&gt;

      With nested resource collection elements, if the number of
      included resources
      is greater than 1, or if only the &lt;code&gt;dir&lt;/code&gt; attribute is
      specified in the &lt;code&gt;&amp;lt;fileset&amp;gt;&lt;/code&gt;, or if the
      &lt;code&gt;file&lt;/code&gt; attribute is also specified, then only
      &lt;code&gt;todir&lt;/code&gt; is allowed.&lt;br /&gt;
      &lt;em&gt;Prior to Apache Ant 1.8.2&lt;/em&gt; the &lt;code&gt;tofile&lt;/code&gt; attribute
      only supported filesystem resources top copy from.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;todir&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The directory to copy to.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;overwrite&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Overwrite existing files even if the destination
      files are newer.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;force&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Overwrite read-only destination
      files.  &lt;em&gt;since Ant 1.8.2&lt;/em&gt;&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;filtering&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Indicates whether token filtering using the &lt;a href=&quot;http://ant.apache.org/manual/using.html#filters&quot;&gt;global
        build-file filters&lt;/a&gt; should take place during the copy.
      &lt;em&gt;Note&lt;/em&gt;: Nested &lt;code&gt;&amp;lt;filterset&amp;gt;&lt;/code&gt; elements will
      always be used, even if this attribute is not specified, or its value is
      &lt;code&gt;false&lt;/code&gt; (&lt;code&gt;no&lt;/code&gt;, or &lt;code&gt;off&lt;/code&gt;).&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;flatten&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Ignore the directory structure of the source files,
      and copy all files into the directory specified by the &lt;code&gt;todir&lt;/code&gt;
      attribute.  Note that you can achieve the same effect by using a
      &lt;a href=&quot;http://ant.apache.org/manual/Types/mapper.html#flatten-mapper&quot;&gt;flatten mapper&lt;/a&gt;.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;includeEmptyDirs&lt;/td&gt;
     &lt;td valign=&quot;top&quot;&gt;Copy any empty directories included in the FileSet(s).
     &lt;/td&gt;
     &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to true.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;failonerror&lt;/td&gt;
     &lt;td valign=&quot;top&quot;&gt;If false, log a warning message, but do not stop the
       build, when the file to copy does not exist or one of the nested
       filesets points to a directory that doesn&#39;t exist or an error occurs
       while copying.
     &lt;/td&gt;
     &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to true.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;verbose&lt;/td&gt;
     &lt;td valign=&quot;top&quot;&gt;Log the files that are being copied.&lt;/td&gt;
     &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;encoding&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The encoding to assume when filter-copying the
    files. &lt;em&gt;since Ant 1.5&lt;/em&gt;.&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;No - defaults to default JVM encoding&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;outputencoding&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The encoding to use when writing the files.
    &lt;em&gt;since Ant 1.6&lt;/em&gt;.&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;No - defaults to the value of the encoding
    attribute if given or the default JVM encoding otherwise.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;enablemultiplemappings&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;
      If true the task will process to all the mappings for a
      given source path. If false the task will only process
      the first file or directory. This attribute is only relevant
      if there is a mapper subelement.
      &lt;em&gt;since Ant 1.6&lt;/em&gt;.&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;No - defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;granularity&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The number of milliseconds leeway to give before
    deciding a file is out of date. This is needed because not every
    file system supports tracking the last modified time to the
    millisecond level. Default is 1 second, or 2 seconds on DOS
    systems.  This can also be useful if source and target files live
    on separate machines with clocks being out of sync.  &lt;em&gt;since Ant
    1.6.2&lt;/em&gt;.&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;No&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;
Parameters specified as nested elements&lt;/h3&gt;
&lt;h4&gt;
fileset or any other resource collection&lt;/h4&gt;
&lt;a href=&quot;http://ant.apache.org/manual/Types/resources.html#collection&quot;&gt;Resource
Collection&lt;/a&gt;s are used to select groups of files to copy.  To use a
resource collection, the &lt;code&gt;todir&lt;/code&gt; attribute must be set.&lt;br /&gt;

Prior to Ant 1.7 only &lt;code&gt;&amp;lt;fileset&amp;gt;&lt;/code&gt; has been
supported as a nested element.&lt;br /&gt;


&lt;h4&gt;
mapper&lt;/h4&gt;
You can define filename transformations by using a nested &lt;a href=&quot;http://ant.apache.org/manual/Types/mapper.html&quot;&gt;mapper&lt;/a&gt; element. The default mapper used by
 &lt;code&gt;&amp;lt;copy&amp;gt;&lt;/code&gt; is the &lt;a href=&quot;http://ant.apache.org/manual/Types/mapper.html#identity-mapper&quot;&gt;identity mapper&lt;/a&gt;.&lt;br /&gt;

  
    &lt;em&gt;Since Ant 1.6.3&lt;/em&gt;,
    one can use a filenamemapper type in place of the mapper element.
  &lt;br /&gt;


Note that the source name handed to the mapper depends on the
resource collection you use.  If you use &lt;code&gt;&amp;lt;fileset&amp;gt;&lt;/code&gt;
or any other collection that provides a base directory, the name
passed to the mapper will be a relative filename, relative to the base
directory.  In any other case the absolute filename of the source will
be used.&lt;br /&gt;


&lt;h4&gt;
filterset&lt;/h4&gt;
&lt;a href=&quot;http://ant.apache.org/manual/Types/filterset.html&quot;&gt;FilterSet&lt;/a&gt;s are used to replace
tokens in files that are copied.
 To use a FilterSet, use the nested &lt;code&gt;&amp;lt;filterset&amp;gt;&lt;/code&gt; element.&lt;br /&gt;


It is possible to use more than one filterset.&lt;br /&gt;


&lt;h4&gt;
filterchain&lt;/h4&gt;
The Copy task supports nested &lt;a href=&quot;http://ant.apache.org/manual/Types/filterchain.html&quot;&gt;
FilterChain&lt;/a&gt;s.&lt;br /&gt;



If &lt;code&gt;&amp;lt;filterset&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;filterchain&amp;gt;&lt;/code&gt; elements are used inside the
same &lt;code&gt;&amp;lt;copy&amp;gt;&lt;/code&gt; task, all &lt;code&gt;&amp;lt;filterchain&amp;gt;&lt;/code&gt; elements are processed first
followed by &lt;code&gt;&amp;lt;filterset&amp;gt;&lt;/code&gt; elements.
&lt;br /&gt;


&lt;h3&gt;
Examples&lt;/h3&gt;
&lt;b&gt;Copy a single file&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy file=&quot;myfile.txt&quot; tofile=&quot;mycopy.txt&quot;/&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copy a single file to a directory&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy file=&quot;myfile.txt&quot; todir=&quot;../some/other/dir&quot;/&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copy a directory to another directory&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;../new/dir&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;src_dir&quot;/&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copy a set of files to a directory&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;../dest/dir&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;src_dir&quot;&amp;gt;
      &amp;lt;exclude name=&quot;**/*.java&quot;/&amp;gt;
    &amp;lt;/fileset&amp;gt;
  &amp;lt;/copy&amp;gt;

  &amp;lt;copy todir=&quot;../dest/dir&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;src_dir&quot; excludes=&quot;**/*.java&quot;/&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copy a set of files to a directory, appending
&lt;code&gt;.bak&lt;/code&gt; to the file name on the fly&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;../backup/dir&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;src_dir&quot;/&amp;gt;
    &amp;lt;globmapper from=&quot;*&quot; to=&quot;*.bak&quot;/&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copy a set of files to a directory, replacing @TITLE@ with Foo Bar
in all files.&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;../backup/dir&quot;&amp;gt;
    &amp;lt;fileset dir=&quot;src_dir&quot;/&amp;gt;
    &amp;lt;filterset&amp;gt;
      &amp;lt;filter token=&quot;TITLE&quot; value=&quot;Foo Bar&quot;/&amp;gt;
    &amp;lt;/filterset&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Collect all items from the current CLASSPATH setting into a
destination directory, flattening the directory structure.&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;dest&quot; flatten=&quot;true&quot;&amp;gt;
    &amp;lt;path&amp;gt;
      &amp;lt;pathelement path=&quot;${java.class.path}&quot;/&amp;gt;
    &amp;lt;/path&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
&lt;b&gt;Copies some resources to a given directory.&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;dest&quot; flatten=&quot;true&quot;&amp;gt;
    &amp;lt;resources&amp;gt;
      &amp;lt;file file=&quot;src_dir/file1.txt&quot;/&amp;gt;
      &amp;lt;url url=&quot;http://ant.apache.org/index.html&quot;/&amp;gt;
    &amp;lt;/resources&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
If the example above didn&#39;t use the flatten attribute,
  the &lt;code&gt;&amp;lt;file&amp;gt;&lt;/code&gt; resource would have returned its full
  path as source and target name and would not have been copied at
  all.  In general it is a good practice to use an explicit mapper
  together with resources that use an absolute path as their
  names.&lt;br /&gt;


&lt;b&gt;Copies the two newest resources into a destination directory.&lt;/b&gt;&lt;br /&gt;

&lt;pre&gt;  &amp;lt;copy todir=&quot;dest&quot; flatten=&quot;true&quot;&amp;gt;
    &amp;lt;first count=&quot;2&quot;&amp;gt;
      &amp;lt;sort&amp;gt;
        &amp;lt;date xmlns=&quot;antlib:org.apache.tools.ant.types.resources.comparators&quot;/&amp;gt;
        &amp;lt;resources&amp;gt;
          &amp;lt;file file=&quot;src_dir/file1.txt&quot;/&amp;gt;
          &amp;lt;file file=&quot;src_dir/file2.txt&quot;/&amp;gt;
          &amp;lt;file file=&quot;src_dir/file3.txt&quot;/&amp;gt;
          &amp;lt;url url=&quot;http://ant.apache.org/index.html&quot;/&amp;gt;
        &amp;lt;/resources&amp;gt;
      &amp;lt;/sort&amp;gt;
    &amp;lt;/first&amp;gt;
  &amp;lt;/copy&amp;gt;
&lt;/pre&gt;
The paragraph following the previous example applies to this
  example as well.&lt;br /&gt;


&lt;strong&gt;Unix Note:&lt;/strong&gt; File permissions are not retained when files
are copied; they end up with the default &lt;code&gt;UMASK&lt;/code&gt; permissions
instead. This
is caused by the lack of any means to query or set file permissions in the
current Java runtimes. If you need a permission-preserving copy function,
use &lt;code&gt;&amp;lt;exec executable=&quot;cp&quot; ... &amp;gt;&lt;/code&gt; instead.
&lt;br /&gt;


&lt;strong&gt;Windows Note:&lt;/strong&gt; If you copy a file to a directory
where that file already exists, but with different casing,
the copied file takes on the case of the original. The workaround is to
&lt;a href=&quot;http://ant.apache.org/manual/Tasks/delete.html&quot;&gt;delete&lt;/a&gt;
the file in the destination directory before you copy it.
&lt;br /&gt;

  
    &lt;strong&gt;&lt;a href=&quot;&quot; name=&quot;encoding&quot;&gt;Important Encoding Note:&lt;/a&gt;&lt;/strong&gt;
    The reason that binary files when filtered get corrupted is that
    filtering involves reading in the file using a Reader class. This
    has an encoding specifing how files are encoded. There are a number
    of different types of encoding - UTF-8, UTF-16, Cp1252, ISO-8859-1,
    US-ASCII and (lots) others. On Windows the default character encoding
    is Cp1252, on Unix it is usually UTF-8. For both of these encoding
    there are illegal byte sequences (more in UTF-8 than for Cp1252).
  &lt;br /&gt;

  
    How the Reader class deals with these illegal sequences is up to the
    implementation
    of the character decoder. The current Sun Java implemenation is to
    map them to legal characters. Previous Sun Java (1.3 and lower) threw
    a MalformedInputException. IBM Java 1.4 also thows this exception.
    It is the mapping of the characters that cause the corruption.
  &lt;br /&gt;

  
    On Unix, where the default is normally UTF-8, this is a &lt;em&gt;big&lt;/em&gt;
    problem, as it is easy to edit a file to contain non US Ascii characters
    from ISO-8859-1, for example the Danish oe character. When this is
    copied (with filtering) by Ant, the character get converted to a
    question mark (or some such thing).
  &lt;br /&gt;

  
    There is not much that Ant can do. It cannot figure out which
    files are binary - a UTF-8 version of Korean will have lots of
    bytes with the top bit set. It is not informed about illegal
    character sequences by current Sun Java implementions.
  &lt;br /&gt;

  
    One trick for filtering containing only US-ASCII is to
    use the ISO-8859-1 encoding. This does not seem to contain
    illegal character sequences, and the lower 7 bits are US-ASCII.
    Another trick is to change the LANG environment variable from
    something like &quot;us.utf8&quot; to &quot;us&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ant.apache.org/manual/Tasks/copy.html&quot;&gt;http://ant.apache.org/manual/Tasks/copy.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/3322820876265643339/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/copy-ant.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3322820876265643339'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3322820876265643339'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/copy-ant.html' title='Copy Ant'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-4620337193223723208</id><published>2012-06-21T02:35:00.001+07:00</published><updated>2012-06-21T02:35:13.503+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse Ant"/><title type='text'>Symlink With Ant</title><content type='html'>&lt;h3&gt;
Description&lt;/h3&gt;
Manages symbolic links on Unix based platforms. Can be used to
make an individual link, delete a link, create multiple links from properties files, 
or create properties files describing links in the specified directories.
Existing links are not overwritten by default.


&lt;br /&gt;
&lt;a href=&quot;http://www.java-tips.org/CoreTypes/fileset.html&quot;&gt;FileSet&lt;/a&gt;s are used to select a
set of links to record, or a set of property files to create links from. &lt;br /&gt;

&lt;h3&gt;
Parameters&lt;/h3&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;0&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;&lt;b&gt;Attribute&lt;/b&gt;&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;&lt;b&gt;Required&lt;/b&gt;&lt;/td&gt;

  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;action&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The type of action to perform, may be &quot;single&quot;, 
    &quot;record&quot;, &quot;recreate&quot; or &quot;delete&quot;.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No, defaults to single.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;

    &lt;td valign=&quot;top&quot;&gt;link&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The name of the link to be created or deleted.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;center&quot;&gt;required for 
    action=&quot;single&quot; or &quot;delete&quot;. Ignored in other actions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;resource&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The resource the link should point to.&lt;/td&gt;

    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;required for action=&quot;single&quot;. Ignored in other actions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;linkfilename&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;The name of the properties file to create in 
    each included directory.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;required for action=&quot;record&quot;. 
    Ignored in other actions.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;overwrite&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;Overwrite existing links or not.&lt;/td&gt;
    &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to false.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td valign=&quot;top&quot;&gt;failonerror&lt;/td&gt;

     &lt;td valign=&quot;top&quot;&gt;Stop build if true, log a warning message, but do not stop the build,
       when the an error occurs if false.
     &lt;/td&gt;
     &lt;td align=&quot;center&quot; valign=&quot;top&quot;&gt;No; defaults to true.&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;
Parameters specified as nested elements&lt;/h3&gt;
&lt;h4&gt;
fileset&lt;/h4&gt;
FileSets
 are used when action = &quot;record&quot; to select directories and linknames to be recorded. 
 They are also used when action = &quot;recreate&quot; to specify both the name of the property 
 files to be processed, and the directories in which they can be found. At least one 
 fileset is required for each case.&lt;br /&gt;


 
&lt;h3&gt;
Examples&lt;/h3&gt;
Make a link named &quot;foo&quot; to a resource named &quot;bar.foo&quot; in subdir:&lt;br /&gt;

  &lt;pre&gt;  &amp;lt;symlink link=&quot;${dir.top}/foo&quot; resource=&quot;${dir.top}/subdir/bar.foo&quot;/&amp;gt;
  &lt;/pre&gt;
Record all links in subdir and it&#39;s descendants in files named
  &quot;dir.links&quot;&lt;br /&gt;


  &lt;pre&gt;  &amp;lt;symlink action=&quot;record&quot; linkfilename=&quot;dir.links&quot;&amp;gt;
     &amp;lt;fileset dir=&quot;${dir.top}&quot; includes=&quot;subdir/**&quot;/&amp;gt;
  &amp;lt;/symlink&amp;gt;
  &lt;/pre&gt;
Recreate the links recorded in the previous example:&lt;br /&gt;


  &lt;pre&gt;  &amp;lt;symlink action=&quot;recreate&quot;&amp;gt;
     &amp;lt;fileset dir=&quot;${dir.top}&quot; includes=&quot;subdir/**/dir.links&quot;/&amp;gt;  
  &amp;lt;/symlink&amp;gt;
  &lt;/pre&gt;
Delete a link named &quot;foo&quot;:
 &lt;br /&gt;
&lt;pre&gt; &amp;lt;symlink action=&quot;delete&quot; link=&quot;${dir.top}/foo&quot;/&amp;gt;
 &lt;/pre&gt;
&lt;strong&gt;Java 1.2 and earlier:&lt;/strong&gt; Due to limitations on executing system
  level commands in &lt;a class=&quot;kLink&quot; href=&quot;http://www.java-tips.org/#&quot; id=&quot;KonaLink3&quot; style=&quot;font-family: inherit !important; font-size: inherit !important; font-weight: inherit !important; position: static; text-decoration: underline !important;&quot;&gt;&lt;span style=&quot;color: blue; font-family: inherit ! important; font-size: inherit ! important; font-weight: inherit ! important; position: static;&quot;&gt;&lt;span class=&quot;kLink&quot; style=&quot;color: blue !important; font-family: inherit !important; font-size: inherit !important; font-weight: inherit !important; position: static;&quot;&gt;Java &lt;/span&gt;&lt;span class=&quot;kLink&quot; style=&quot;color: blue !important; font-family: inherit !important; font-size: inherit !important; font-weight: inherit !important; position: static;&quot;&gt;versions&lt;/span&gt;&lt;/span&gt;&lt;/a&gt; earlier than 1.3 this task may have difficulty
  operating with a relative path in ANT_HOME. The typical symptom is an 
  IOException where ant can&#39;t find /some/working/directory${ANT_HOME}/bin/antRun
  or something similar. The workaround is to change your ANT_HOME environment
  variable to an absolute path, which will remove the /some/working/directory portion
  of the above path and allow ant to find the correct commandline execution script.
 
  &lt;br /&gt;
&lt;strong&gt;LIMITATIONS:&lt;/strong&gt; Because Java has no direct support for
  handling symlinks this task divines them by comparing canonical and
  absolute paths. On non-unix systems this may cause false positives.
  Furthermore, any operating system on which the command
  &lt;code&gt;ln -s &amp;lt;linkname&amp;gt; &amp;lt;resourcename&amp;gt;&lt;/code&gt; is not a valid 
  command on the command line will not be able to use action=&quot;single&quot; or 
  action=&quot;recreate&quot;. Action=&quot;record&quot; and action=delete should still work. Finally, 
  the lack of support for symlinks in Java means that all links are recorded as 
  links to the &lt;strong&gt;canonical&lt;/strong&gt; resource name. Therefore the link:
  &lt;code&gt;link --&amp;gt; subdir/dir/../foo.bar&lt;/code&gt; will be recorded as
  &lt;code&gt;link=subdir/foo.bar&lt;/code&gt; and restored as
  &lt;code&gt;link --&amp;gt; subdir/foo.bar&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/4620337193223723208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/symlink-with-ant.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4620337193223723208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/4620337193223723208'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/symlink-with-ant.html' title='Symlink With Ant'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-7320089619967603318</id><published>2012-06-21T01:06:00.001+07:00</published><updated>2012-06-21T01:06:09.054+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse Ant"/><title type='text'>ANT SYMLINK</title><content type='html'>&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;&lt;div align=&quot;left&quot; id=&quot;leftcol&quot; valign=&quot;top&quot;&gt;
&lt;div align=&quot;center&quot;&gt;
&lt;br /&gt;

&lt;br /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;td align=&quot;left&quot; valign=&quot;top&quot;&gt;
&lt;div id=&quot;before_source_code&quot;&gt;

&lt;h1&gt;
Ant example source code file (symlink.xml)&lt;/h1&gt;
&lt;blockquote&gt;

This example &lt;a href=&quot;http://ant.apache.org/&quot;&gt;Ant&lt;/a&gt; source code file (symlink.xml) is included in the &lt;a href=&quot;http://devdaily.com/&quot;&gt;DevDaily.com&lt;/a&gt;
&quot;&lt;a href=&quot;http://www.devdaily.com/java/jwarehouse&quot;&gt;Java Source Code
Warehouse&lt;/a&gt;&quot; project. The intent of this project is to help you &quot;&lt;i&gt;Learn Java by Example&lt;/i&gt;&quot; &lt;sup&gt;&lt;i&gt;TM&lt;/i&gt;&lt;/sup&gt;.&lt;br /&gt;

&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div id=&quot;tags&quot;&gt;

&lt;h2&gt;
Java - Ant tags/keywords&lt;/h2&gt;
&lt;blockquote&gt;

creates, deletes, dir, error, error, file, file, link, link, os, os, should, test, this&lt;br /&gt;

&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div id=&quot;source_code&quot;&gt;

&lt;h2&gt;
The symlink.xml source code&lt;/h2&gt;
&lt;pre&gt;&amp;lt;?xml version=&quot;1.0&quot;?&amp;gt;

&amp;lt;!--

/*
 * Since the initial version of this file was deveolped on the clock on
 * an NSF grant I should say the following boilerplate:
 *
 * This material is based upon work supported by the National Science
 * Foundaton under Grant No. EIA-0196404. Any opinions, findings, and
 * conclusions or recommendations expressed in this material are those
 * of the author and do not necessarily reflect the views of the
 * National Science Foundation.
 */

--&amp;gt;

&amp;lt;project name=&quot;symlink-test&quot; basedir=&quot;.&quot; default=&quot;all&quot;&amp;gt;

  &amp;lt;!-- 
       Since the symlink task and some of these targets rely on
       calls to exec, it may be possible for the JVM to outrun the 
       execution of the command line  system calls, so this value is
       the number of seconds we give the operating system to
       catch up before executing a task that depends on the 
       completion of previous tasks. This delay is also added to
       the end of each target so junit doesn&#39;t go testing things
       before they have finnished (hopefully). Tweak if needed.
  --&amp;gt;

  &amp;lt;property name=&quot;delay&quot; value=&quot;3&quot;/&amp;gt;
 
  &amp;lt;property name=&quot;tdir&quot; value=&quot;${basedir}/test-working&quot;/&amp;gt;

  &amp;lt;target name=&quot;setup&quot;&amp;gt;
      &amp;lt;delete dir=&quot;${tdir}&quot;/&amp;gt;
      &amp;lt;mkdir dir=&quot;${tdir}&quot;/&amp;gt;
  &amp;lt;/target&amp;gt;

  &amp;lt;target name=&quot;all&quot;
       depends=&quot;setup, test-single, test-delete, test-record, test-recreate, teardown&quot;/&amp;gt;
 
  &amp;lt;!-- test for action = single --&amp;gt;
  &amp;lt;!-- 
    Creates:
         File: ${tdir}/symlink.test
         Link: ${tdir}/singletest
  --&amp;gt;
  &amp;lt;target name=&quot;test-single&quot;&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symlink.test&quot;/&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symlink.test&quot; 
             link=&quot;${tdir}/singletest&quot; 
             failonerror=&quot;yes&quot;/&amp;gt;
    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt; 
    &amp;lt;available file=&quot;${tdir}/symlink.test&quot; 
               property=&quot;test.single.file.created&quot;/&amp;gt;
    &amp;lt;available file=&quot;${tdir}/singletest&quot; 
               property=&quot;test.single.link.created&quot;/&amp;gt;
  &amp;lt;/target&amp;gt;



  &amp;lt;!-- test for action = delete  (no calls to command line so no sleep) --&amp;gt;

  &amp;lt;!-- 
    Creates:
         (none)
    Deletes:
         Link: ${tdir}/singletest
  --&amp;gt;

  &amp;lt;target name=&quot;test-delete&quot;&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symlink.test&quot;/&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symlink.test&quot; 
             link=&quot;${tdir}/singletest&quot; 
             failonerror=&quot;yes&quot;/&amp;gt;
    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt; 

    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/singletest&quot; failonerror=&quot;yes&quot;/&amp;gt;
    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symlink.test&quot; failonerror=&quot;no&quot;/&amp;gt;
    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt; 

    &amp;lt;available file=&quot;${tdir}/symlink.test&quot; 
               property=&quot;test.delete.file.still.there&quot;/&amp;gt;
    &amp;lt;available file=&quot;${tdir}/singletest&quot; 
               property=&quot;test.delete.link.still.there&quot;
               value=&quot;ERROR: link deletion failed&quot;/&amp;gt;
    
  &amp;lt;/target&amp;gt;



  &amp;lt;!-- test for action = record --&amp;gt;

  &amp;lt;!-- 
    Creates:
         Dir:  ${tdir}/symtest1
         Dir:  ${tdir}/symtest1/symtest2
         Dir:  ${tdir}/symtest1/symtest3
         File: ${tdir}/symtest1/file1
         File: ${tdir}/symtest1/symtest2/file2
         File: ${tdir}/symtest1/symtest3/fileA
         File: ${tdir}/symtest1/symtest3/fileB
         File: ${tdir}/symtest1/symtest3/fileC
         Link: ${tdir}/symtest1/link1==&amp;gt;${tdir}/symtest1/file1
         Link: ${tdir}/symtest1/link2==&amp;gt;${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/symtest2/link3==&amp;gt;
                                           ${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/dirlink==&amp;gt;${tdir}/symtest1/symtest3
         Link: ${tdir}/symtest1/dirlink2==&amp;gt;${tdir}/symtest1/symtest3
         Link: ${tdir}/symtest1/dirlink3==&amp;gt;${tdir}/symtest1/symtest3
         File: ${tdir}/symtest1/recorded.links
         File: ${tdir}/symtest1/symtest2/recorded.links
    Deletes:
         (none)
  --&amp;gt;

  &amp;lt;target name=&quot;test-record&quot;&amp;gt;

    &amp;lt;mkdir dir=&quot;${tdir}/symtest1&quot;/&amp;gt;
    &amp;lt;mkdir dir=&quot;${tdir}/symtest1/symtest2&quot;/&amp;gt;
    &amp;lt;mkdir dir=&quot;${tdir}/symtest1/symtest3&quot;/&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symtest1/file1&quot;/&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symtest1/symtest2/file2&quot;/&amp;gt;

    &amp;lt;touch file=&quot;${tdir}/symtest1/symtest3/fileA&quot;/&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symtest1/symtest3/fileB&quot;/&amp;gt;
    &amp;lt;touch file=&quot;${tdir}/symtest1/symtest3/fileC&quot;/&amp;gt;

    &amp;lt;symlink resource=&quot;${tdir}/symtest1/file1&quot; 
             link=&quot;${tdir}/symtest1/link1&quot; 
             failonerror=&quot;no&quot; /&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest2/file2&quot; 
             link=&quot;${tdir}/symtest1/link2&quot; 
             failonerror=&quot;no&quot; /&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest2/file2&quot; 
             link=&quot;${tdir}/symtest1/symtest2/link3&quot; 
             failonerror=&quot;no&quot; /&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest3&quot;
             link=&quot;${tdir}/symtest1/dirlink&quot;
             failonerror=&quot;no&quot; /&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest3&quot; 
             link=&quot;${tdir}/symtest1/dirlink2&quot;
             failonerror=&quot;no&quot;/&amp;gt;
    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest3&quot; 
             link=&quot;${tdir}/symtest1/dirlink3&quot;
             failonerror=&quot;no&quot;/&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt; 

    &amp;lt;symlink action=&quot;record&quot; linkfilename=&quot;recorded.links&quot;&amp;gt;
       &amp;lt;fileset dir=&quot;${tdir}/symtest1&quot; includes=&quot;**/**&quot;/&amp;gt;
    &amp;lt;/symlink&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt; 

    &amp;lt;!-- Test to see if the directories were created --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1&quot;
               type=&quot;dir&quot;
               property=&quot;test.record.dir1.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2&quot;
               type=&quot;dir&quot;
               property=&quot;test.record.dir2.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3&quot;
               type=&quot;dir&quot;
               property=&quot;test.record.dir3.created&quot;/&amp;gt;

    &amp;lt;!-- Test to see if the Files were created --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/file1&quot;
               property=&quot;test.record.file1.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2/file2&quot;
               property=&quot;test.record.file2.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/fileA&quot;
               property=&quot;test.record.fileA.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/fileB&quot;
               property=&quot;test.record.fileB.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/fileC&quot;
               property=&quot;test.record.fileC.created&quot;/&amp;gt;

    &amp;lt;!-- Test to see if the links were created --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/link1&quot;
               property=&quot;test.record.link1.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/link2&quot;
               property=&quot;test.record.link2.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2/link3&quot;
               property=&quot;test.record.link3.created&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/dirlink&quot;
               property=&quot;test.record.dirlink.created&quot;/&amp;gt;

    &amp;lt;!-- this is redundant for this test, but used in the recreate test --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/dirlink2&quot; 
               property=&quot;test.record.dirlink2.created&quot;/&amp;gt;

    &amp;lt;!-- Test to see if the linkfiles were created --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/recorded.links&quot;
               property=&quot;test.record.dir1.recorded&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2/recorded.links&quot;
               property=&quot;test.record.dir2.recorded&quot;/&amp;gt;

    &amp;lt;!-- THIS should not be set --&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/recorded.links&quot;
               property=&quot;test.record.dir3.recorded&quot;
               value=&quot;ERROR: symtest3/recorded.links should not exist&quot;/&amp;gt;


  &amp;lt;/target&amp;gt;

  &amp;lt;!-- test for action = recreate --&amp;gt;

  &amp;lt;!-- 
    Deletes:
         Link: ${tdir}/symtest1/link1==&amp;gt;${tdir}/symtest1/file1
         Link: ${tdir}/symtest1/link2==&amp;gt;${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/symtest2/link3==&amp;gt;
                                           ${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/dirlink==&amp;gt;${tdir}/symtest1/symtest3
         Link: ${tdir}/symtest1/dirlink3==&amp;gt;${tdir}/symtest1/symtest3

    Creates
         Link: ${tdir}/symtest1/dirlink3==&amp;gt;${tdir}/symtest1/symtest2

    Recreates:
         Link: ${tdir}/symtest1/link1==&amp;gt;${tdir}/symtest1/file1
         Link: ${tdir}/symtest1/link2==&amp;gt;${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/symtest2/link3==&amp;gt;
                                           ${tdir}/symtest1/symtest2/file2
         Link: ${tdir}/symtest1/dirlink==&amp;gt;${tdir}/symtest1/symtest3

    Should Change:
         Link: ${tdir}/symtest1/dirlink3==&amp;gt;${tdir}/symtest1/symtest2
               to
               ${tdir}/symtest1/dirlink3==&amp;gt;${tdir}/symtest1/symtest3

    Should Not Create (bug 25181):
         Link: ${tdir}/symtest1/symtest3/dirlink2==&amp;gt;${tdir}/symtest1/symtest3
  --&amp;gt;

  &amp;lt;target name=&quot;test-recreate&quot; depends=&quot;test-record&quot;&amp;gt;

    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symtest1/link1&quot;/&amp;gt;
    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symtest1/link2&quot;/&amp;gt;
    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symtest1/symtest2/link3&quot;/&amp;gt;
    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symtest1/dirlink&quot;/&amp;gt;
    &amp;lt;!-- dirlink2 intentionally not deleted to test bug 25181 --&amp;gt;
    &amp;lt;symlink action=&quot;delete&quot; link=&quot;${tdir}/symtest1/dirlink3&quot;/&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt;  

    &amp;lt;symlink resource=&quot;${tdir}/symtest1/symtest2&quot; 
             link=&quot;${tdir}/symtest1/dirlink3&quot;
             failonerror=&quot;no&quot;/&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt;  

    &amp;lt;available file=&quot;${tdir}/symtest1/link1&quot;
               property=&quot;test.recreate.link1.not.removed&quot;
               value=&quot;ERROR: rm -f symtest1/link1 failed&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/link2&quot;
               property=&quot;test.recreate.link2.not.removed&quot;
               value=&quot;ERROR: rm -f symtest1/link2 failed&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2/link3&quot;
               property=&quot;test.recreate.link3.not.removed&quot;
               value=&quot;ERROR: rm -f symtest1/symtest2/link3 failed&quot;/&amp;gt;

     &amp;lt;available file=&quot;${tdir}/symtest1/zdirlink&quot;
               property=&quot;test.recreate.zdirlink.not.removed&quot;
               value=&quot;ERROR: rm -f symtest1/zdirlink failed&quot;/&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt;  

    &amp;lt;symlink action=&quot;recreate&quot;&amp;gt;
      &amp;lt;fileset dir=&quot;${tdir}/symtest1&quot; includes=&quot;**/recorded.links&quot;/&amp;gt;
    &amp;lt;/symlink&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt;  

    &amp;lt;available file=&quot;${tdir}/symtest1/link1&quot;
               property=&quot;test.recreate.link1.recreated&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/link2&quot;
               property=&quot;test.recreate.link2.recreated&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest2/link3&quot;
               property=&quot;test.recreate.link3.recreated&quot;/&amp;gt;

    &amp;lt;available file=&quot;${tdir}/symtest1/dirlink&quot;
               property=&quot;test.recreate.dirlink.recreated&quot;/&amp;gt;

    &amp;lt;!-- this should not get set --&amp;gt;
    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/symtest3&quot; 
               property=&quot;test.recreate.dirlink2.recreated.twice&quot;
               value=&quot;ERROR: dirlink2 was created a second time (bug 25181)&quot;/&amp;gt;

    &amp;lt;touch file=&quot;${tdir}/symtest1/dirlink3/WhereAmI&quot;/&amp;gt;

    &amp;lt;sleep seconds=&quot;${delay}&quot;/&amp;gt;  

    &amp;lt;available file=&quot;${tdir}/symtest1/symtest3/WhereAmI&quot; 
               property=&quot;test.recreate.dirlink3.was.altered&quot;/&amp;gt;
  &amp;lt;/target&amp;gt;


&amp;lt;!-- CALL THIS to clean things up afterwards --&amp;gt;

  &amp;lt;target name=&quot;teardown&quot;&amp;gt;
    &amp;lt;delete dir=&quot;${tdir}&quot;/&amp;gt;
  &amp;lt;/target&amp;gt;

&amp;lt;/project&amp;gt;
&lt;/pre&gt;
&lt;div id=&quot;after_source_code&quot;&gt;

&lt;h2&gt;
Other Ant examples (source code examples)&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/7320089619967603318/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/ant-symlink.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7320089619967603318'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7320089619967603318'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/ant-symlink.html' title='ANT SYMLINK'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-7871239633849653112</id><published>2012-06-21T00:55:00.001+07:00</published><updated>2012-06-21T00:55:20.551+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse Ant"/><title type='text'>Eclipse Ant Builder</title><content type='html'>&lt;h1&gt;
Tutorial: Hello World with Apache Ant&lt;/h1&gt;
This document provides a step by step tutorial for starting java programming with Apache Ant.
It does &lt;b&gt;not&lt;/b&gt; contain deeper knowledge about Java or Ant. This tutorial has the goal
to let you see, how to do the easiest steps in Ant.&lt;br /&gt;




&lt;h2&gt;
Content&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#prepare&quot;&gt;Preparing the project&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#four-steps&quot;&gt;Enhance the build file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#enhance&quot;&gt;Enhance the build file&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#ext-libs&quot;&gt;Using external libraries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html#resources&quot;&gt;Resources&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a href=&quot;&quot; name=&quot;prepare&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Preparing the project&lt;/h2&gt;
We want to separate the source from the generated files, so our java source files will
be in &lt;tt&gt;src&lt;/tt&gt; folder. All generated files should be under &lt;tt&gt;build&lt;/tt&gt;, and there
splitted into several subdirectories for the individual steps: &lt;tt&gt;classes&lt;/tt&gt; for our compiled
files and &lt;tt&gt;jar&lt;/tt&gt; for our own JAR-file.&lt;br /&gt;

We have to create only the &lt;tt&gt;src&lt;/tt&gt; directory. (Because I am working on Windows, here is 
the win-syntax - translate to your shell):&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;md src
&lt;/pre&gt;
The following simple Java class just prints a fixed message out to STDOUT,
so just write this code into &lt;tt&gt;src\oata\HelloWorld.java&lt;/tt&gt;.&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;package oata;

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println(&quot;Hello World&quot;);
    }
}
&lt;/pre&gt;
Now just try to compile and run that:
&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;md build\classes
javac -sourcepath src -d build\classes src\oata\HelloWorld.java
java -cp build\classes oata.HelloWorld
&lt;/pre&gt;
which will result in
&lt;pre class=&quot;output&quot;&gt;Hello World
&lt;/pre&gt;
Creating a jar-file is not very difficult. But creating a &lt;i&gt;startable&lt;/i&gt; jar-file needs more steps: create a
manifest-file containing the start class, creating the target directory and archiving the files.&lt;br /&gt;

&lt;pre class=&quot;code&quot;&gt;echo Main-Class: oata.HelloWorld&amp;gt;myManifest
md build\jar
jar cfm build\jar\HelloWorld.jar myManifest -C build\classes .
java -jar build\jar\HelloWorld.jar
&lt;/pre&gt;
&lt;b&gt;Note:&lt;/b&gt; Do not have blanks around the &amp;gt;-sign in the &lt;tt&gt;echo Main-Class&lt;/tt&gt; instruction because it would 
falsify it!&lt;br /&gt;



&lt;a href=&quot;&quot; name=&quot;four-steps&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Four steps to a running application&lt;/h2&gt;
After finishing the java-only step we have to think about our build process. We &lt;i&gt;have&lt;/i&gt; to compile our code, otherwise we couldn&#39;t
start the program. Oh - &quot;start&quot; - yes, we could provide a target for that. We &lt;i&gt;should&lt;/i&gt; package our application.
Now it&#39;s only one class - but if you want to provide a download, no one would download several hundreds files ...
(think about a complex Swing GUI - so let us create a jar file. A startable jar file would be nice ... And it&#39;s a
good practise to have a &quot;clean&quot; target, which deletes all the generated stuff. Many failures could be solved just
by a &quot;clean build&quot;.&lt;br /&gt;


By default Ant uses &lt;tt&gt;build.xml&lt;/tt&gt; as the name for a buildfile, so our &lt;tt&gt;.\build.xml&lt;/tt&gt; would be:&lt;br /&gt;

&lt;pre class=&quot;code&quot;&gt;&amp;lt;project&amp;gt;

    &amp;lt;target name=&quot;clean&quot;&amp;gt;
        &amp;lt;delete dir=&quot;build&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;compile&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;build/classes&quot;/&amp;gt;
        &amp;lt;javac srcdir=&quot;src&quot; destdir=&quot;build/classes&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;jar&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;build/jar&quot;/&amp;gt;
        &amp;lt;jar destfile=&quot;build/jar/HelloWorld.jar&quot; basedir=&quot;build/classes&quot;&amp;gt;
            &amp;lt;manifest&amp;gt;
                &amp;lt;attribute name=&quot;Main-Class&quot; value=&quot;oata.HelloWorld&quot;/&amp;gt;
            &amp;lt;/manifest&amp;gt;
        &amp;lt;/jar&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;run&quot;&amp;gt;
        &amp;lt;java jar=&quot;build/jar/HelloWorld.jar&quot; fork=&quot;true&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

&amp;lt;/project&amp;gt;
&lt;/pre&gt;
Now you can compile, package and run the application via&lt;br /&gt;

&lt;pre class=&quot;code&quot;&gt;ant compile
ant jar
ant run
&lt;/pre&gt;
Or shorter with&lt;br /&gt;

&lt;pre class=&quot;code&quot;&gt;ant compile jar run
&lt;/pre&gt;
While having a look at the buildfile, we will see some similar steps between Ant and the java-only commands:
&lt;br /&gt;
&lt;table&gt;
&lt;tbody&gt;
&lt;tr&gt;
  &lt;th&gt;java-only&lt;/th&gt;
  &lt;th&gt;Ant&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
  &lt;td valign=&quot;top&quot;&gt;&lt;pre class=&quot;code&quot;&gt;md build\classes
javac
    -sourcepath src
    -d build\classes
    src\oata\HelloWorld.java
echo Main-Class: oata.HelloWorld&amp;gt;mf
md build\jar
jar cfm
    build\jar\HelloWorld.jar
    mf
    -C build\classes
    .



java -jar build\jar\HelloWorld.jar
  &lt;/pre&gt;
&lt;/td&gt;
  &lt;td valign=&quot;top&quot;&gt;&lt;pre class=&quot;code&quot;&gt;&amp;lt;mkdir dir=&quot;build/classes&quot;/&amp;gt;
&amp;lt;javac
    srcdir=&quot;src&quot;
    destdir=&quot;build/classes&quot;/&amp;gt;
&lt;i&gt;&amp;lt;!-- automatically detected --&amp;gt;&lt;/i&gt;
&lt;i&gt;&amp;lt;!-- obsolete; done via manifest tag --&amp;gt;&lt;/i&gt;
&amp;lt;mkdir dir=&quot;build/jar&quot;/&amp;gt;
&amp;lt;jar
    destfile=&quot;build/jar/HelloWorld.jar&quot;

    basedir=&quot;build/classes&quot;&amp;gt;
    &amp;lt;manifest&amp;gt;
        &amp;lt;attribute name=&quot;Main-Class&quot; value=&quot;oata.HelloWorld&quot;/&amp;gt;
    &amp;lt;/manifest&amp;gt;
&amp;lt;/jar&amp;gt;
&amp;lt;java jar=&quot;build/jar/HelloWorld.jar&quot; fork=&quot;true&quot;/&amp;gt;
  &lt;/pre&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;a href=&quot;&quot; name=&quot;enhance&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Enhance the build file&lt;/h2&gt;
Now we have a working buildfile we could do some enhancements: many time you are referencing the
same directories, main-class and jar-name are hard coded, and while invocation you have to remember
the right order of build steps.&lt;br /&gt;

The first and second point would be addressed with &lt;i&gt;properties&lt;/i&gt;, the third with a special property - an attribute
of the &amp;lt;project&amp;gt;-tag and the fourth problem can be solved using dependencies.&lt;br /&gt;



&lt;pre class=&quot;code&quot;&gt;&amp;lt;project name=&quot;HelloWorld&quot; basedir=&quot;.&quot; default=&quot;main&quot;&amp;gt;

    &amp;lt;property name=&quot;src.dir&quot;     value=&quot;src&quot;/&amp;gt;

    &amp;lt;property name=&quot;build.dir&quot;   value=&quot;build&quot;/&amp;gt;
    &amp;lt;property name=&quot;classes.dir&quot; value=&quot;${build.dir}/classes&quot;/&amp;gt;
    &amp;lt;property name=&quot;jar.dir&quot;     value=&quot;${build.dir}/jar&quot;/&amp;gt;

    &amp;lt;property name=&quot;main-class&quot;  value=&quot;oata.HelloWorld&quot;/&amp;gt;



    &amp;lt;target name=&quot;clean&quot;&amp;gt;
        &amp;lt;delete dir=&quot;${build.dir}&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;compile&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;${classes.dir}&quot;/&amp;gt;
        &amp;lt;javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${classes.dir}&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;jar&quot; depends=&quot;compile&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;${jar.dir}&quot;/&amp;gt;
        &amp;lt;jar destfile=&quot;${jar.dir}/${ant.project.name}.jar&quot; basedir=&quot;${classes.dir}&quot;&amp;gt;
            &amp;lt;manifest&amp;gt;
                &amp;lt;attribute name=&quot;Main-Class&quot; value=&quot;${main-class}&quot;/&amp;gt;
            &amp;lt;/manifest&amp;gt;
        &amp;lt;/jar&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;run&quot; depends=&quot;jar&quot;&amp;gt;
        &amp;lt;java jar=&quot;${jar.dir}/${ant.project.name}.jar&quot; fork=&quot;true&quot;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;clean-build&quot; depends=&quot;clean,jar&quot;/&amp;gt;

    &amp;lt;target name=&quot;main&quot; depends=&quot;clean,run&quot;/&amp;gt;

&amp;lt;/project&amp;gt;
&lt;/pre&gt;
Now it&#39;s easier, just do a &lt;tt class=&quot;code&quot;&gt;ant&lt;/tt&gt; and you will get&lt;br /&gt;

&lt;pre class=&quot;output&quot;&gt;Buildfile: build.xml

clean:

compile:
    [mkdir] Created dir: C:\...\build\classes
    [javac] Compiling 1 source file to C:\...\build\classes

jar:
    [mkdir] Created dir: C:\...\build\jar
      [jar] Building jar: C:\...\build\jar\HelloWorld.jar

run:
     [java] Hello World

main:

BUILD SUCCESSFUL
&lt;/pre&gt;
&lt;a href=&quot;&quot; name=&quot;ext-libs&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Using external libraries&lt;/h2&gt;
Somehow told us not to use syso-statements. For log-Statements we should use a Logging-API - customizable on a high
degree (including switching off during usual life (= not development) execution). We use Log4J for that, because &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;it is not part of the JDK (1.4+) and we want to show how to use external libs&lt;/li&gt;
&lt;li&gt;it can run under JDK 1.2 (as Ant)&lt;/li&gt;
&lt;li&gt;it&#39;s highly configurable&lt;/li&gt;
&lt;li&gt;it&#39;s from Apache ;-)&lt;/li&gt;
&lt;/ul&gt;
We store our external libraries in a new directory &lt;tt&gt;lib&lt;/tt&gt;. Log4J can be
&lt;a href=&quot;http://www.apache.org/dist/logging/log4j/1.2.13/logging-log4j-1.2.13.zip&quot;&gt;downloaded [1]&lt;/a&gt; from Logging&#39;s Homepage.
Create the &lt;tt&gt;lib&lt;/tt&gt; directory and extract the log4j-1.2.9.jar into that lib-directory. After that we have to modify
our java source to use that library and our buildfile so that this library could be accessed during compilation and run.
&lt;br /&gt;

Working with Log4J is documented inside its manual. Here we use the &lt;i&gt;MyApp&lt;/i&gt;-example from the
&lt;a href=&quot;http://logging.apache.org/log4j/docs/manual.html&quot;&gt;Short Manual [2]&lt;/a&gt;. First we have to modify the java source to
use the logging framework:&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;package oata;

&lt;b&gt;import org.apache.log4j.Logger;&lt;/b&gt;
&lt;b&gt;import org.apache.log4j.BasicConfigurator;&lt;/b&gt;

public class HelloWorld {
    &lt;b&gt;static Logger logger = Logger.getLogger(HelloWorld.class);&lt;/b&gt;

    public static void main(String[] args) {
        &lt;b&gt;BasicConfigurator.configure();&lt;/b&gt;
        &lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;logger.info(&quot;Hello World&quot;);&lt;/b&gt;&lt;/span&gt;          // the old SysO-statement
    }
}
&lt;/pre&gt;
Most of the modifications are &quot;framework overhead&quot; which has to be done once. The blue line is our &quot;old System-out&quot;
statement.&lt;br /&gt;

Don&#39;t try to run &lt;tt&gt;ant&lt;/tt&gt; - you will only get lot of compiler errors. Log4J is not inside the classpath so we have
to do a little work here. But do not change the CLASSPATH environment variable! This is only for this project and maybe
you would break other environments (this is one of the most famous mistakes when working with Ant). We introduce Log4J
(or to be more precise: all libraries (jar-files) which are somewhere under &lt;tt&gt;.\lib&lt;/tt&gt;) into our buildfile:&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;&amp;lt;project name=&quot;HelloWorld&quot; basedir=&quot;.&quot; default=&quot;main&quot;&amp;gt;
    ...
    &lt;b&gt;&amp;lt;property name=&quot;lib.dir&quot;     value=&quot;lib&quot;/&amp;gt;&lt;/b&gt;

    &lt;b&gt;&amp;lt;path id=&quot;classpath&quot;&amp;gt;&lt;/b&gt;
        &lt;b&gt;&amp;lt;fileset dir=&quot;${lib.dir}&quot; includes=&quot;**/*.jar&quot;/&amp;gt;&lt;/b&gt;
    &lt;b&gt;&amp;lt;/path&amp;gt;&lt;/b&gt;

    ...

    &amp;lt;target name=&quot;compile&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;${classes.dir}&quot;/&amp;gt;
        &amp;lt;javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${classes.dir}&quot; &lt;b&gt;classpathref=&quot;classpath&quot;&lt;/b&gt;/&amp;gt;
    &amp;lt;/target&amp;gt;

    &amp;lt;target name=&quot;run&quot; depends=&quot;jar&quot;&amp;gt;
        &amp;lt;java fork=&quot;true&quot; &lt;b&gt;classname=&quot;${main-class}&quot;&lt;/b&gt;&amp;gt;
            &lt;b&gt;&amp;lt;classpath&amp;gt;&lt;/b&gt;
                &lt;b&gt;&amp;lt;path refid=&quot;classpath&quot;/&amp;gt;&lt;/b&gt;
                &lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;&amp;lt;path location=&quot;${jar.dir}/${ant.project.name}.jar&quot;/&amp;gt;&lt;/b&gt;&lt;/span&gt;
            &lt;b&gt;&amp;lt;/classpath&amp;gt;&lt;/b&gt;
        &amp;lt;/java&amp;gt;
    &amp;lt;/target&amp;gt;

    ...

&amp;lt;/project&amp;gt;
&lt;/pre&gt;
In this example we start our application not via its Main-Class manifest-attribute, because we could not provide
a jarname &lt;i&gt;and&lt;/i&gt; a classpath. So add our class in the red line to the already defined path and start as usual. Running
&lt;tt&gt;ant&lt;/tt&gt; would give (after the usual compile stuff):&lt;br /&gt;


&lt;pre class=&quot;output&quot;&gt;[java] 0 [main] INFO oata.HelloWorld  - Hello World
&lt;/pre&gt;
What&#39;s that? &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;i&gt;[java]&lt;/i&gt; Ant task running at the moment&lt;/li&gt;
&lt;li&gt;&lt;i&gt;0&lt;/i&gt; &lt;span&gt;sorry don&#39;t know - some Log4J stuff&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;i&gt;[main]&lt;/i&gt; the running thread from our application &lt;/li&gt;
&lt;li&gt;&lt;i&gt;INFO&lt;/i&gt; log level of that statement
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;oata.HelloWorld&lt;/i&gt; source of that statement
&lt;/li&gt;
&lt;li&gt;&lt;i&gt;-&lt;/i&gt; separator&lt;/li&gt;
&lt;li&gt;&lt;i&gt;Hello World&lt;/i&gt; the message&lt;/li&gt;
&lt;/ul&gt;
For another layout ... have a look inside Log4J&#39;s documentation about using other PatternLayout&#39;s.


&lt;a href=&quot;&quot; name=&quot;config-files&quot;&gt;
&lt;h2&gt;
Configuration files&lt;/h2&gt;
Why we have used Log4J? &quot;It&#39;s highly configurable&quot;? No - all is hard coded! But that is not the debt of Log4J - it&#39;s
ours. We had coded &lt;tt&gt;BasicConfigurator.configure();&lt;/tt&gt; which implies a simple, but hard coded configuration. More
confortable would be using a property file. In the java source delete the BasicConfiguration-line from the main() method
(and the related import-statement). Log4J will search then for a configuration as described in it&#39;s manual. Then create 
a new file &lt;tt&gt;src/log4j.properties&lt;/tt&gt;. That&#39;s the default name for Log4J&#39;s configuration and using that name would make 
life easier - not only the framework knows what is inside, you too!&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;log4j.rootLogger=DEBUG, &lt;b&gt;stdout&lt;/b&gt;

log4j.appender.&lt;b&gt;stdout&lt;/b&gt;=org.apache.log4j.ConsoleAppender

log4j.appender.&lt;b&gt;stdout&lt;/b&gt;.layout=org.apache.log4j.PatternLayout
log4j.appender.&lt;b&gt;stdout&lt;/b&gt;.layout.ConversionPattern=&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;%m%n&lt;/b&gt;&lt;/span&gt;
&lt;/pre&gt;
This configuration creates an output channel (&quot;Appender&quot;) to console named as &lt;tt&gt;stdout&lt;/tt&gt; which prints the
message (%m) followed by a line feed (%n) - same as the earlier System.out.println() :-) Oooh kay - but we haven&#39;t
finished yet. We should deliver the configuration file, too. So we change the buildfile:&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;    ...
    &amp;lt;target name=&quot;compile&quot;&amp;gt;
        &amp;lt;mkdir dir=&quot;${classes.dir}&quot;/&amp;gt;
        &amp;lt;javac srcdir=&quot;${src.dir}&quot; destdir=&quot;${classes.dir}&quot; classpathref=&quot;classpath&quot;/&amp;gt;
        &lt;b&gt;&amp;lt;copy todir=&quot;${classes.dir}&quot;&amp;gt;&lt;/b&gt;
            &lt;b&gt;&amp;lt;fileset dir=&quot;${src.dir}&quot; excludes=&quot;**/*.java&quot;/&amp;gt;&lt;/b&gt;
        &lt;b&gt;&amp;lt;/copy&amp;gt;&lt;/b&gt;
    &amp;lt;/target&amp;gt;
    ...
&lt;/pre&gt;
This copies all resources (as long as they haven&#39;t the suffix &quot;.java&quot;) to the build directory, so we could
start the application from that directory and these files will included into the jar.&lt;br /&gt;



&lt;/a&gt;&lt;a href=&quot;&quot; name=&quot;junit&quot;&gt;
&lt;h2&gt;
Testing the class&lt;/h2&gt;
In this step we will introduce the usage of the JUnit [3] testframework in combination with Ant. Because Ant
has a built-in JUnit 3.8.2 you could start directly using it. Write a test class in &lt;tt&gt;src\HelloWorldTest.java&lt;/tt&gt;: &lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;public class HelloWorldTest extends junit.framework.TestCase {

    public void testNothing() {
    }
    
    public void testWillAlwaysFail() {
        fail(&quot;An error message&quot;);
    }
    
}&lt;/pre&gt;
&lt;/a&gt;&lt;a href=&quot;&quot; name=&quot;junit&quot;&gt;Because we dont have real business logic to test, this test class is very small: just show how to start. For 
further information see the JUnit documentation [3] and the manual of &lt;/a&gt;&lt;a href=&quot;http://ant.apache.org/manual/Tasks/junit.html&quot;&gt;junit&lt;/a&gt; task.
Now we add a junit instruction to our buildfile:&lt;br /&gt;


&lt;pre class=&quot;code&quot;&gt;    ...

    &amp;lt;path &lt;b&gt;id=&quot;application&quot;&lt;/b&gt; location=&quot;${jar.dir}/${ant.project.name}.jar&quot;/&amp;gt;

    &amp;lt;target name=&quot;run&quot; depends=&quot;jar&quot;&amp;gt;
        &amp;lt;java fork=&quot;true&quot; classname=&quot;${main-class}&quot;&amp;gt;
            &amp;lt;classpath&amp;gt;
                &amp;lt;path refid=&quot;classpath&quot;/&amp;gt;
                &lt;b&gt;&amp;lt;path refid=&quot;application&quot;/&amp;gt;&lt;/b&gt;
            &amp;lt;/classpath&amp;gt;
        &amp;lt;/java&amp;gt;
    &amp;lt;/target&amp;gt;
    
    &lt;b&gt;&amp;lt;target name=&quot;junit&quot; depends=&quot;jar&quot;&amp;gt;
        &amp;lt;junit printsummary=&quot;yes&quot;&amp;gt;
            &amp;lt;classpath&amp;gt;
                &amp;lt;path refid=&quot;classpath&quot;/&amp;gt;
                &amp;lt;path refid=&quot;application&quot;/&amp;gt;
            &amp;lt;/classpath&amp;gt;
            
            &amp;lt;batchtest fork=&quot;yes&quot;&amp;gt;
                &amp;lt;fileset dir=&quot;${src.dir}&quot; includes=&quot;*Test.java&quot;/&amp;gt;
            &amp;lt;/batchtest&amp;gt;
        &amp;lt;/junit&amp;gt;
    &amp;lt;/target&amp;gt;&lt;/b&gt;

    ...

&lt;/pre&gt;
We reuse the path to our own jar file as defined in run-target by
  giving it an ID and making it globally available.
The &lt;tt&gt;printsummary=yes&lt;/tt&gt; lets us see more detailed information than just a &quot;FAILED&quot; or &quot;PASSED&quot; message.
How much tests failed? Some errors? Printsummary lets us know. The classpath is set up to find our classes.
To run tests the &lt;tt&gt;batchtest&lt;/tt&gt; here is used, so you could easily add more test classes in the future just
by naming them &lt;tt&gt;*Test.java&lt;/tt&gt;. This is a common naming scheme.&lt;br /&gt;


After a &lt;tt class=&quot;code&quot;&gt;ant junit&lt;/tt&gt; you&#39;ll get:&lt;br /&gt;


&lt;pre class=&quot;output&quot;&gt;...
junit:
    [junit] Running HelloWorldTest
    [junit] Tests run: 2, Failures: 1, Errors: 0, Time elapsed: 0,01 sec
    [junit] Test HelloWorldTest FAILED

BUILD SUCCESSFUL
...
&lt;/pre&gt;
We can also produce a report. Something that you (and other) could read after closing the shell .... 
There are two steps: 1. let &amp;lt;junit&amp;gt; log the information and 2. convert these to something readable (browsable).&lt;br /&gt;


&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;    ...
    &lt;b&gt;&amp;lt;property name=&quot;report.dir&quot;  value=&quot;${build.dir}/junitreport&quot;/&amp;gt;&lt;/b&gt;
    ...
    &amp;lt;target name=&quot;junit&quot; depends=&quot;jar&quot;&amp;gt;
        &lt;b&gt;&amp;lt;mkdir dir=&quot;${report.dir}&quot;/&amp;gt;&lt;/b&gt;
        &amp;lt;junit printsummary=&quot;yes&quot;&amp;gt;
            &amp;lt;classpath&amp;gt;
                &amp;lt;path refid=&quot;classpath&quot;/&amp;gt;
                &amp;lt;path refid=&quot;application&quot;/&amp;gt;
            &amp;lt;/classpath&amp;gt;
            
            &lt;b&gt;&amp;lt;formatter type=&quot;xml&quot;/&amp;gt;&lt;/b&gt;
            
            &amp;lt;batchtest fork=&quot;yes&quot; &lt;b&gt;todir=&quot;${report.dir}&quot;&lt;/b&gt;&amp;gt;
                &amp;lt;fileset dir=&quot;${src.dir}&quot; includes=&quot;*Test.java&quot;/&amp;gt;
            &amp;lt;/batchtest&amp;gt;
        &amp;lt;/junit&amp;gt;
    &amp;lt;/target&amp;gt;
    
    &lt;b&gt;&amp;lt;target name=&quot;junitreport&quot;&amp;gt;
        &amp;lt;junitreport todir=&quot;${report.dir}&quot;&amp;gt;
            &amp;lt;fileset dir=&quot;${report.dir}&quot; includes=&quot;TEST-*.xml&quot;/&amp;gt;
            &amp;lt;report todir=&quot;${report.dir}&quot;/&amp;gt;
        &amp;lt;/junitreport&amp;gt;
    &amp;lt;/target&amp;gt;&lt;/b&gt;
&lt;/pre&gt;
Because we would produce a lot of files and these files would be written to the current directory by default,
we define a report directory, create it before running the &lt;tt&gt;junit&lt;/tt&gt; and redirect the logging to it. The log format
is XML so &lt;tt&gt;junitreport&lt;/tt&gt; could parse it. In a second target &lt;tt&gt;junitreport&lt;/tt&gt; should create a browsable 
HTML-report for all generated xml-log files in the report directory. Now you can open the ${report.dir}\index.html and
see the result (looks something like JavaDoc).&lt;br /&gt;
Personally I use two different targets for junit and junitreport. Generating the HTML report needs some time and you dont
need the HTML report just for testing, e.g. if you are fixing an error or a integration server is doing a job.
&lt;br /&gt;





&lt;a href=&quot;&quot; name=&quot;resources&quot;&gt;&lt;/a&gt;
&lt;h2&gt;
Resources&lt;/h2&gt;
&lt;pre&gt;    [1] &lt;a href=&quot;http://www.apache.org/dist/logging/log4j/1.2.13/logging-log4j-1.2.13.zip&quot;&gt;http://www.apache.org/dist/logging/log4j/1.2.13/logging-log4j-1.2.13.zip&lt;/a&gt;
    [2] &lt;a href=&quot;http://logging.apache.org/log4j/docs/manual.html&quot;&gt;http://logging.apache.org/log4j/docs/manual.html&lt;/a&gt;
    [3] &lt;a href=&quot;http://www.junit.org/index.htm&quot;&gt;http://www.junit.org/index.htm&lt;/a&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/7871239633849653112/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/eclipse-ant-builder.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7871239633849653112'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7871239633849653112'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/eclipse-ant-builder.html' title='Eclipse Ant Builder'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5721612657963056358</id><published>2012-06-11T18:15:00.001+07:00</published><updated>2012-06-11T18:15:14.920+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JAVA"/><title type='text'>Java SQL Connect</title><content type='html'>&lt;br /&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
Are you asking ‘Could I connect Java application/applet to database like MySQL?’ and the answer is definitely Yes.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
You can use JDBC (Java Database Connectivity) to connect your Java application/applet with database. So Let’s start.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
First, Create new Project named anything you want, for example Javasql by click File-&amp;gt;New Project.&lt;/div&gt;
&lt;div class=&quot;wp-caption alignnone&quot; style=&quot;background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(228, 228, 228); color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 7px 2px; text-align: center; width: 410px;&quot;&gt;
&lt;img alt=&quot;newProject&quot; class=&quot;size-full wp-image-74&quot; src=&quot;http://ferdidolot.files.wordpress.com/2009/06/newproject.jpg?w=630&quot; style=&quot;border: 0px; margin: 0px; max-width: 100%; padding: 0px;&quot; title=&quot;newProject&quot; /&gt;&lt;div class=&quot;wp-caption-text&quot; style=&quot;font-size: 11px; line-height: 12px; padding: 5px 0px 0px !important;&quot;&gt;
newProject&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
then you’ll be on this frame&lt;/div&gt;
&lt;div class=&quot;wp-caption alignnone&quot; style=&quot;background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(228, 228, 228); color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 7px 2px; text-align: center; width: 560px;&quot;&gt;
&lt;img alt=&quot;javaapps&quot; class=&quot;size-full wp-image-76&quot; src=&quot;http://ferdidolot.files.wordpress.com/2009/06/javaapps.jpg?w=630&quot; style=&quot;border: 0px; margin: 0px; max-width: 100%; padding: 0px;&quot; title=&quot;javaapps&quot; /&gt;&lt;div class=&quot;wp-caption-text&quot; style=&quot;font-size: 11px; line-height: 12px; padding: 5px 0px 0px !important;&quot;&gt;
javaapps&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
then click next,&amp;nbsp; then give Project Name and set Project Localtion&lt;/div&gt;
&lt;div class=&quot;wp-caption alignnone&quot; style=&quot;background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(228, 228, 228); color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 7px 2px; text-align: center; width: 560px;&quot;&gt;
&lt;img alt=&quot;nameProject&quot; class=&quot;size-full wp-image-75&quot; src=&quot;http://ferdidolot.files.wordpress.com/2009/06/nameproject.jpg?w=630&quot; style=&quot;border: 0px; margin: 0px; max-width: 100%; padding: 0px;&quot; title=&quot;nameProject&quot; /&gt;&lt;div class=&quot;wp-caption-text&quot; style=&quot;font-size: 11px; line-height: 12px; padding: 5px 0px 0px !important;&quot;&gt;
nameProject&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
then finish.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
Second, you must have JDBC MySQL Driver before you can start to connect your Java program to database. But since we use Netbeans , this has been done. Just simply add the library to your project library. Right click in Library on the Project you use.&amp;nbsp;&lt;img alt=&quot;addLibrary&quot; class=&quot;alignnone size-full wp-image-77&quot; src=&quot;http://ferdidolot.files.wordpress.com/2009/06/addlibrary.jpg?w=630&quot; style=&quot;display: inline; margin: 0px 0px 10px; max-width: 100%; padding: 0px;&quot; title=&quot;addLibrary&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
Then choose MySQL JDBC Driver&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
&lt;img alt=&quot;addLib&quot; class=&quot;alignnone size-full wp-image-78&quot; src=&quot;http://ferdidolot.files.wordpress.com/2009/06/addlib.jpg?w=630&quot; style=&quot;display: inline; margin: 0px 0px 10px; max-width: 100%; padding: 0px;&quot; title=&quot;addLib&quot; /&gt;&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
Then Click Add Libary.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
So now we can connect to MySQL database. Here is the example how you can connect to MySQL.&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
Here, we use interface Connection.&lt;/div&gt;
&lt;pre style=&quot;background-color: whitesmoke; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(230, 230, 230); color: #555555; font-size: 12px; line-height: 20px; margin-bottom: 15px; overflow: auto; padding: 10px 20px 0px 15px; width: 593px;&quot;&gt;package javasql;
import com.mysql.jdbc.Driver;
import java.sql.*;
/**
 *
 * @author Ferdiansyah Dolot
 */
public class Connect {
    public Connect() throws SQLException{
        makeConnection();
    } 

    private Connection koneksi;  

     public  Connection makeConnection() throws SQLException {
        if (koneksi == null) {
             new Driver();
            // buat koneksi
             koneksi = DriverManager.getConnection(
                       &quot;jdbc:mysql://localhost/databasename&quot;,
                       &quot;username&quot;,
                       &quot;password&quot;);
         }
         return koneksi;
     }  

     public static void main(String args[]) {
         try {
             Connect c = new Connect();
             System.out.println(&quot;Connection established&quot;);
         }
         catch (SQLException e) {
             e.printStackTrace();
             System.err.println(&quot;Connection Failure&quot;);
         }  

    }
}&lt;/pre&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
In example above we create connection to MySQL from creating object of Driver and get connection from DriverManager (get Connection will return&amp;nbsp;&lt;em&gt;Connection&lt;/em&gt;&amp;nbsp;Object type), with parameter the url, username, and password. The url above means the database is located in localhost and the name is databasename.You can also add port for MySQL so the url looks : “jdbc:mysql://localhost:3306/databasename”. (See&amp;nbsp;&lt;a href=&quot;http://www.linklogger.com/TCP3306.htm&quot; style=&quot;color: #008dcf; text-decoration: none;&quot;&gt;port 3306&lt;/a&gt;).&lt;br /&gt;So now we can make a connection to MySQL database. Now, how can we do SQL statement like update, delete, insert, etc?&lt;/div&gt;
&lt;div style=&quot;background-color: white; color: #555555; font-family: Arial, Tahoma, Verdana; font-size: 12px; line-height: 20px; padding: 0px 0px 15px; text-align: justify;&quot;&gt;
We will discuss this in Java MySQL JDBC Tutorial using NetBeans (Part 2).&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ferdidolot.wordpress.com/2009/06/14/java-mysql-jdbc-tutorial-using-netbeans-part-1/&quot;&gt;http://ferdidolot.wordpress.com/2009/06/14/java-mysql-jdbc-tutorial-using-netbeans-part-1/&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5721612657963056358/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/java-sql-connect.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5721612657963056358'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5721612657963056358'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/java-sql-connect.html' title='Java SQL Connect'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-7103078854807206165</id><published>2012-06-08T17:28:00.002+07:00</published><updated>2012-06-08T17:28:37.867+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CUSTOM ROM ANDROID"/><title type='text'>SAMSUNG MOBILE FMWARE</title><content type='html'>&lt;a href=&quot;http://www.sammobile.com/firmware/?page=3&amp;amp;t=1&amp;amp;o=1&amp;amp;m=GT-S5830&amp;amp;r=2#regiona&quot; target=&quot;_blank&quot;&gt;http://www.sammobile.com/firmware/?page=3&amp;amp;t=1&amp;amp;o=1&amp;amp;m=GT-S5830&amp;amp;r=2#regiona&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/7103078854807206165/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/samsung-mobile-fmware.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7103078854807206165'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/7103078854807206165'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/samsung-mobile-fmware.html' title='SAMSUNG MOBILE FMWARE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-8998101180478968608</id><published>2012-06-08T17:25:00.003+07:00</published><updated>2012-06-08T17:25:49.049+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CUSTOM ROM ANDROID"/><title type='text'>UNROOT GALAXY ACE</title><content type='html'>&lt;a href=&quot;http://handzmentallist.blogspot.com/2012/04/cara-unroot-samsung-galaxy-ace.html&quot;&gt;http://handzmentallist.blogspot.com/2012/04/cara-unroot-samsung-galaxy-ace.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/8998101180478968608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/unroot-galaxy-ace.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8998101180478968608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8998101180478968608'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/unroot-galaxy-ace.html' title='UNROOT GALAXY ACE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5276354253672591067</id><published>2012-06-08T15:32:00.002+07:00</published><updated>2012-06-08T16:47:31.927+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CUSTOM ROM ANDROID"/><title type='text'>ROM GALAXY ACE 2.3.4</title><content type='html'>&lt;b&gt;GALAXY ACE 2.3.4&lt;/b&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.proghita.com/root-sederhana-gingerbread-2-3-4-galaxy-ace-ala-proghita/&quot;&gt;http://www.proghita.com/root-sederhana-gingerbread-2-3-4-galaxy-ace-ala-proghita/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;PARTISI SDCARD For Android&lt;/b&gt; &lt;br /&gt;
&lt;a href=&quot;http://note.izor.web.id/2011/05/cara-membagi-partisi-sd-card-pada.html&quot;&gt;http://note.izor.web.id/2011/05/cara-membagi-partisi-sd-card-pada.html&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5276354253672591067/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/rom-galaxy-ace-234.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5276354253672591067'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5276354253672591067'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/rom-galaxy-ace-234.html' title='ROM GALAXY ACE 2.3.4'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-8606215170087048152</id><published>2012-06-04T11:24:00.001+07:00</published><updated>2012-06-04T11:27:49.345+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>PHP Regular Expression</title><content type='html'>Regular Expression atau Regex, merupakan sebuah teknik atau cara 
untuk mencari persamaan - presamaan atau mencari string yang di cocokan 
dengan string tertentu,dalam php yang paling banyak digunakan adalah 
PCRE atau (Perl Compatible Regular Expressions), penggunaan dari regex 
sebebenarnya cukup luas, secara umum digunkan untuk mencari string 
(kata, huruf, simbol) dalam kumpulan-kumpulan string, misalnya ada 
sebuah string &quot;saya pergi sekolah&quot;, dalam string tersebut terdapat 
beberapa kata, dan kita ingin mencari beberapa kata dengan kondisi 
tertentu, misalnya mencari kata dengan awalan p, atau mencari kata 
dengan akhiran a atau mencari kata di antara kata saya dan kata sekolah,
 di sinilah regex berperan, untuk mencari string dalam string dengan 
patern (kondisi) tertentu.&lt;br /&gt;
Untuk lebih memahami mari kita mencoba implementasi regex, dengan membuats sebuah program sederahan&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_820231&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// buat&amp;nbsp; string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcdefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// tulisakan hasil string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika Program tersebut di jalankan tentu saja string yang tampil 
adalah string secara keseluruhan, karena kita tidak menerapkan fungsi 
regex di dalamnya, sekarang kita akan mencoba mencari string &quot;abc&quot; dalam
 string yang ada, secara simple nya kita akan mencoba mencari apakah 
string &quot;abc&quot; ada dalam kumpulan string dengan variabel $string&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_559143&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcdefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/abc/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Program di atas akan menghasilkan 1 (true), itu karena patern string 
yang kita gunakan (abc) ada dalam string sebelemunya, dengan menggunakan
 preg_match() hasil yang di dapatkan akan berupa 1 jika patern ditemukan
 atau sebaliknya akan manampilkan 0 jika patern tidak ditemukan, tetapi 
yang perlu di ingat adalah penggunaan preg_match() dalam sekala yang 
lebih besar tidaklah terlalu baik, penggunaan strpos() atau strstr() 
akan jauh lebih baik dibandingkan dengan preg_match(), tetapi disini 
kita akan menggunakan preg_match(), karena ini juga contoh yang 
sederhana :)&lt;br /&gt;
&lt;h3&gt;

Mecocokan Awalan dari String&lt;/h3&gt;
Disini kita akan mencoba mencari string yang awalan dari string 
tersebut kita tentukan dalam patern kita, misalnya mencari string yang 
berawalan P, atau mencari string yang berawalan m dan lainya, dalam 
regex kita akan menggunkan simbol ^ sebagai penanda bahwa kita mencari 
kecocokan awalan dari string yang kita berikan, &lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_519369&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
14&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
15&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
16&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcdefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// mencoba mencocokan awalan dari string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/^abc/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;))&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;//jika awalan ditemukan&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String dimulai dengan abc&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;//jika awalan tidak ditemukan&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;string tidak di awali dengan abc&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika kita menjalankan program di atas, kita akan mendapatkan pesan &lt;i&gt;String dimulai dengan abc&lt;/i&gt;,
 tanda / dan \ merupakan delimeter (cakupan) dari regex yang kita 
berikan, sedangkan simbol ^ mencocokan awalan dari string tanpa 
memperdulikan string setelahnya&lt;br /&gt;
&lt;h3&gt;

case insensitive&lt;/h3&gt;
Jika kita menggunakan code di atas untuk mencari string dengan awaln 
ABC dengan patern seperti if (preg_match(&quot;/^ABC/&quot;, $string)) &lt;i&gt;hasinya string tidak di awali dengan abc&lt;/i&gt;,
 karena memang tidak ada string yang di awali dengan ABC, walapun pada 
hakikatnya abc = ABC, tetapi dalam programming kadang itu bisa menjadi 
sesuatu yang berbeda, untuk itu kita harus memberi tau kan kepada regex 
kita bahwa hal itu tidaklah berbeda, dengan cara menambahkan huruf i di 
akhir delimeter patern yang kita berikan, dengan begitu regex tidak akan
 memperdulikan huruf kecil dan huruf besar, atau kita akan mencari 
awalan string tanpa memperdulikan huruf besar atau tidak, seperti ABC, 
AbC, abc, ABc dll&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_427801&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
14&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
15&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
16&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcdefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// mencoba mencocokan awalan dari string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/^ABC/i&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;))&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;//jika awalan ditemukan&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String dimulai dengan abc&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php comments&quot;&gt;//jika awalan tidak ditemukan&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;string tidak di awali dengan abc&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number15 index14 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number16 index15 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3&gt;

Mecocokan Akhiran dari String&lt;/h3&gt;
Jika tadi kita sudah membahas cara sederhana untuk mencari kecocokan 
string di awalan string, sekarang kita akan mencoba mencari kecocokan di
 akhiran string, caranya tidak jauh berbeda dengan cara sebelumunya, 
kita tetap meggunakan simbol ^ sebagai patern regex, hanya bedanya 
simbol ^ kita berikan di awal patern regex dan menambahkan patern \z di 
akhir, misalnya kita mencari string yang berakhiran 89 maka patern yang 
kita berikan adalah preg_match(&quot;/89\z/i&quot;, $string), tetapi dalam 
implentasinya banyak yang melakukan kesalahan dalam menerapakan regex 
yang mencari kecocokan di akhiran string dengan menggunkan simbol $, 
sebenarnya itu salah, seharusnya kita menggunkan patern \z untuk mencari
 kecocokan di akhiran string, karena jika menggunakan simbol $ saja 
hasilnya akan selalu true (1) jika memang patern ditemukan, tetapi 
masalahnya bagaimana jika masih ada baris selanjutnya ? , tentu saja 
hasilnya tidak akan sesuai dengan harapn kita, untuk itulah simbol 
patern $ tidak diperlukan.kecuali jika memang kita mencari akhiran dalam
 string mempunyai banyak baris., seperti contoh berikut&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_337363&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;//string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcdefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/89\z/i&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;))&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String dikahiri dengan 89&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String tidak diakhiri dengan 89&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Dan jika string yang kita gunakan mempunyai baris-baris lainya kitaa seharunya menggunakan regex seperti berikut&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_650385&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
14&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;//string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &#39;abcdefghijklmnopqrstuv&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;wxyz0123456789&#39;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/^89$/i&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;))&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String dikahiri dengan 89&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String tidak diakhiri dengan 89&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number14 index13 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Perbedaanya cukup jelas kan, penggunaan patern preg_match(&quot;/89\z/i&quot;, 
$string) dengan patern preg_match(&quot;/^89$/&quot;,$string), patern - patern 
tersebut menunjukan perbedaan string yang mempunyai baris dengan string 
yang tidak mempunyai baris, penggunaan seperti inilah yang perlu di 
perhatikan, jika tidak kita pasti beranggapan bahwa patern kita salah 
atau sebaliknya :)&lt;br /&gt;
&lt;h3&gt;

Meta characters&lt;/h3&gt;
Di awal kita sudah mengenal beberapa simbol yang kita gunakan dalam 
regex, seperti simbol ^ yang menunjukan awal dari string, dam simbol $ 
dan \z  yang menunjukan akhir dari string, masing-masing dari simbol 
tersebut mempunyai fungsi dan arti tersendiri dalam regex,tetapi dalam 
regex masih banyak simbol - simbol lainya yang juga memiliki arti dan 
fungsi tersendiri, seperti berikut&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;. (full stop)&lt;/li&gt;
&lt;li&gt;^ (Caret)&lt;/li&gt;
&lt;li&gt;* (Asterix)&lt;/li&gt;
&lt;li&gt;+ (Plus)&lt;/li&gt;
&lt;li&gt;? (Question Mark)&lt;/li&gt;
&lt;li&gt;{ (Opening Curly brace)&lt;/li&gt;
&lt;li&gt;} (Closing Curly brace)&lt;/li&gt;
&lt;li&gt;[ (Opening Brace)&lt;/li&gt;
&lt;li&gt;] (Closing Brace)&lt;/li&gt;
&lt;li&gt;\ (Back Slah)&lt;/li&gt;
&lt;li&gt;| (Pipe)&lt;/li&gt;
&lt;li&gt;( (Opening Parens)&lt;/li&gt;
&lt;li&gt;( (Closing Parens)&lt;/li&gt;
&lt;/ul&gt;
Kita akan mencoba membahas satu persatu dalam tutorial ini, yang 
paling adalah kita mengerti apa mereka (simbol tersebut), misalnya 
penggunaan \ (Black slah) digunakan ketika kita akan meng-escape 
karakter terntentu seperti &amp;lt; atau &amp;gt; atau + atau karakter yang 
termasuk dalam meta characters di atas, misalnya kita akan mengescape 
karakter dalam string 1+1, kita akan mencari karakter dengan awalan 1+1 
dalam string tertentu&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_35462&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
11&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
12&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
13&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;//string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;1+1=2&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;if&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/^1\+1/i&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;))&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String diawali dengan 1+1&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;else&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number11 index10 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;String tidak diawali dengan 1+1&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number12 index11 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number13 index12 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika program tersebut di jalankan, kita akan mendapatkan hasil String
 diawali dengan 1+1, karena patern 1+1 ditemukan dalam string fungsi \ 
(back slah) diatas akan membiarkan tanda + sebagai tanda +, bukan 
sebagai meta characters,dan jika kita tidak memberikan simbol \ maka 
hasilnya akan  String tidak diawali dengan 1+1, akrena patern tidak 
cocok, regex meng-anggap bahwa tanda + merupakan meta characters, jika 
dalam percobaan teman-teman menemukan string yang menggunakan \ maka 
simbol \ harus di escape terlebih dahulu dengan memberikan simbol \ 
double (\\) sehingga simbol \ dalam string akan di anggap sebagai patern
 bukan sebagai meta characters.&lt;br /&gt;
&lt;h3&gt;

Meta characters in Actions&lt;/h3&gt;
Saya harap sampai disini teman-teman masih belum bosan :D, jika di 
awal kita telah membahas simbol ^, $ dan \ maka sekarang kita mencoba 
membahas sedikit tentang meta characters yang lainnya, seperti misalnya 
penggunaan simbol [ dan ], beberapa waktu lalu sempat seorang teman 
bertanya kepada saya masalah perbedaan tanda tersebut dengan simbol (), 
mudah-mudahan tutorial ini bisa menjawabnya&lt;br /&gt;
simbol [ dan ] digunakan untuk memberitahukan kepada regex bahwa kita 
menggunakan patern yang lebih spesipik, misalnya hanya [aiueo] saja, 
atau [a-z] saja, atau [0-9] saja dan aptern yang lainya, tanda - 
menunjukan range (sampai) dalam kondisi tertentu seperti a sampai z atau
 0 sampai 9, seperti contoh berikut&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_966460&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// string&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;big&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/b[aiueo]g/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika kita  jalankan program di atas akan menghasilkan true(1), karena 
preg_match() menemukan patern yang kita berikan (cocok), kenapa ? karena
 pada regex diatas kita memberikan patern 
preg_match(&quot;/b[aiueo]g/&quot;,$string) yang artinya kita mencari kata &quot;b?g&quot; 
dan huruf di antara b dan g bisa berbentuk &quot;aiueo&quot;m jadi misalnya dalam 
string terdapat kata big maka hasilnya akan true karena i terdapat dalam
 patern kita, dan jika seandainya dalam string terdapat kata bug, maka 
nulinya akan tetap true(1), karena u ada dalam patern yang kita berikan,
 simple bukan ? yang perlu di ingat adalah meta characters tidak akan 
bekerja jika kita masukan dapal regex [ dan ], misalnya 
preg_match(&quot;/b[^1\+1]g/&quot;, $string),jadi penggunaan simbol [ dan ] hanya 
untuk mencari kecocokan dalam ruang lingkup tertentu saja&lt;br /&gt;
Dan bagaiaman jika kita ingin mencari string yang cocok tetapi 
didalamnya terdapat salah satu meta characters di atas ? atau mencari 
string yang cocok dalam range tertentu, memang benar, penggunaan meta 
characters dalam simbol [ dan ] tidak diperbolehkan, tetapi kadang - 
kadang boleh :D, tetapi dengan kondisi tertentu, misalnya kita ingin 
mencari string yang tidak di awali dengan string b dalam string, ingat 
TIDAK di awali, bukan di AWALI, berikut contohnya&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_573762&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/[^b]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt; &lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$key&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;=&amp;gt;&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$key&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39; -&amp;gt; &#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika program di atas di jalankan kan, kita akan mendapatkan hasil 
0-&amp;gt;a, karena hanya dua string tersebut yang tidak di awali dengan 
string b, masih bingung ya ?, jika kita kembali ke awal, penggunaan 
simbol [ dan ] menunjukan penggunaan yang lebih spesipik, string [a-z] 
dan [0-9], dalam string yang kita berikan terdapat dua cakupan, maka 
regex meng-anggap bahwa itu dua range yang berbeda, itulah penyebabnya 
kenapa kita mendapatkan hasil 0-&amp;gt;a, sekarang sudah mengertikan ? &lt;br /&gt;
Sekarang mari kita merubah sedikit program kita, jika pada awalnya  
kita menggunakan fungsi preg_match(), sekarang kita akan mencoba 
menggunakan fungsi preg_match_all() dalam mencari string yang TIDAK 
DIAWALI dengan string b dengan patern 
preg_match_all(&quot;/[^b]/&quot;,$string,$matches)
&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_116026&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/[^b]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt; &lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$key&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;=&amp;gt;&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika program tersebut kita jalankan hasilnya adalah 
acefghijklmnopqrstuvwxyz0123456789, coba perhatikan hasilnya, tidak ada 
string b kan ? , ini karena kita mencari semua karakter yang tidak sama 
dengan string b /[^b]/, berbeda dengan penggunaan preg_match(), 
preg_match_all() lebih kepada hasil yang menunjukan kecocokan pada 
string, nah dengan demikian kita bisa menarik keluar string terntentu 
dari string tersebut, misalnya kita ingin mencari string  yang tidak 
sama dengan huruf dari 0 -9 dari string tersebut, dengan menggunakan 
preg_match_all() kita bisa melakukannya, seperti contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_856296&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
10&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;abcefghijklmnopqrstuvwxyz0123456789&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/[^0-9]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt; &lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$key&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;=&amp;gt;&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number10 index9 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
hasil dari program tersebut adalah abcefghijklmnopqrstuvwxyz, 
sekarang sudah mengerti kan penggunaan preg_match() dan preg_match_all()
 ? dan kita bisa melihat tanda ^ dalam simbol [ dan ], di sini kita bisa
 menyimpulkan bahwa simbol ^ jika berada dalam simbol [ dan ] bukan 
berarti awalan atau akhiran, tetapi menunjukan kondisi NOT atau TIDAK.&lt;br /&gt;
&lt;h3&gt;

Lebih jauh tentang Escaping Character&lt;/h3&gt;
Disini kita akan lebih kapada bagaimana memanfaatkan simbol \ dalam 
meng-escape karakter terentu, meng-sacape bisa di artikan sabagai 
membaypass, atau melewati sehingga karekter teresbut bisa di 
proses.misalnya kita akan mencari string yang berada dalam simbol [ dan 
], contohnya seperti berikut&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_446365&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;ini adalah [stringsaya]&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/[\[\]]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;[0] &lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika kita menjalankan program di atas maka hasilnya akan kosong atau 
hanya [], karena kita hanya memberikan patern untuk string yang cocok 
dengan simbol [ dan ], jika kita perhatikan patern tersebut tanpa 
menggunakan simbol black slah \ maka bentuknya akan seperti /[[]]/, dan 
jika kita hanya mencari dan megambil string yang berada di antara apitan
 simbol [ dan ] kita harus memberikan meta characters yang berbeda, yang
 menunjukan string apapun yang berada di antara simbol [ dan ], dengan 
catatan kita tidak menggunakan simbol [ dan ] sebagai regex, seperti 
contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_382950&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;ini adalah [stringsaya]&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/\[.*\]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;print_r(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika Program tersebut di jalankan akan menampilkan [stringsaya] dalam
 susun array, dan bandingkan regex yang ada dengan regex sebelumnya, 
pasti teman-teman bisa memahami maksudnya&lt;br /&gt;
sekarang kita mencoba meta characters . (full stop), simbol ini akan 
mencocokan semua string kecuali di pisahkan oleh bari baru seperti \n 
atau \r, dan jika kita ingin mencari semua string yang tidak 
memperdulikan baris baru seperti pemisahan \r dan \n kita cukup 
menambahkan flag \s di akhir delimeter regex yang kita berikan, seperti 
contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_521927&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;sex at noon taxes&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/s.x/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika program di jalankan, hasilnya akan true (1), karena preg_match()
 menemukan 1 patern yang cocok, arti regex tersebut dapat di artikan 
seperti halnya kita menccari string di antara string s dan x tetapi 
hanya satu karakter saja, tidak perduli karakter itu berbentuk apa, 
misalnya sex, six, sox, s0x,s3x, daln lainya, jika karakternya berbentuk
 seix atau seex maka hasilnya akan 0 atau preg_match() tidak menemukan 1
 patern yang cocok&lt;br /&gt;
Sekarang mari kita coba untuk string yang memiiki baris yang dipisahkan oleh \r atau \n, seperti contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_107757&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;sex&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;\n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;at&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;\n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;noon&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;\n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;taxes&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;.&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;\n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php functions&quot;&gt;nl2br&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/\s/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
jika program di jalankan hasilnya akan menunjukan string yang cocok 
dengan patern dan di pisahkan oleh pindah baris seperti \r dan \n, dan 
pada akhir akan tampil angka 4 yang menunjukan jumlah dari pindah baris 
yang ada karena kita menggunakan preg_match_all().&lt;br /&gt;
meta characters selajutnya adalah simbol *, simbol * digunakan untuk 
mencocokan string apa saja seperti penggunaan .*, simbol * akan 
meng-anggap cocok setiap string yang ada sebelum mapun sesudah dari 
patern yang kita berikan, bingung ya, let take it in action&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_612503&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;php&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/ph*p/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Hasil dari script di atas akan menghasilkan nilai 1, karena kita 
mencari kecocokan ada tidaknya string sesudah string h dari patern yang 
kita berikan, ada dan tidaknya string  setelah string h tidak menjadi 
masalah, karena simbol * akan menghasilkan nilai satu, jika string 
berbentuk pp atau phhhhp maka hasilnya akan tetap 1, intinya kita 
mencari string yang cocok dengan p????p ? merupakan pengganti dari 
simbol *, jadi ada tidaknya string sesudah maupun sebelum string h akan 
di anggap ada karena kita menggunakan meta characters *&lt;br /&gt;
berbeda dengan simbol +, jika simbol * mencocokan semaunya, simbol + 
merupakan kebalikanya, jika menggunakan simbol * string pp dinaggap 
memiliki kecocokan maka jika kita menggunakan simbol + maka string pp 
tidak memiliki kecocokan dengan patern yang kita berikan, lihat contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_519700&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;pp&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/ph+p/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Hasilnya akan 0, karena simbol + tidak meng-anggap ada patern yang 
cocok, Berbeda juga dengan simbol ?, penggunaan simbol ? hampir sama 
dengan simbol + dan *, hanya saja simbol ? digunakan untuk optional 
regex, seperti .*? yang mengartikan semuanya,&lt;br /&gt;
Yang paling sering digunakan dalam regex sebenarnya adalah simbol { 
dan }, karena dengan menggunakan simbol ini regex menjadi lebih ampuh 
dalam mencocokan patern dengan string, misalnya kita ingin mencari 
string numeric dalam sebuah string yang jumlahnya sebanyak 3 digit saja,
 seperti contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_476800&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;PHP123&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;preg_match(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/PHP[0-9]{3}/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Dalam regex tersebut kita memberikan patern untuk mencari dan 
mencocokan string dengan patern yang ita berikan, singkatnya kita 
mencari angka dalam string yang jumlah digitnya 3 (tiga), patern [0-9] 
menunjukan kalo kita mencari jenis numeric sedangkan {3} menujukan kalo 
kita mencari yang jumlah digitnya sebanyak 3 digit&lt;br /&gt;
&lt;h3&gt;

Special Sequences&lt;/h3&gt;
Sequences merupakan pradefined dalam class yang kita gunakan, 
digunakan untuk menggantikan beberapa regex yang panjang sehingga 
menjadi lebih singkat, Sequences di lambangkan dengan huruf dan di 
letakan di belakang delimeter regex, berikut beberapa jenis dan 
fungsinya
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;\d digunakan untuk mencocokan semua jenis angka, sama dengan [0-9]&lt;/li&gt;
&lt;li&gt;\D digunakan untuk mencocokan semua jenis yang bukan angka sama dengan [^0-9]&lt;/li&gt;
&lt;li&gt;\s digunakan untuk mencocokan semua whitespaces, sama dengan [\t\n\r\f\v]&lt;/li&gt;
&lt;li&gt;\S digunakan untuk mencocokan semua non whitespaces, sama dengan [^\t\n\r\f\v]&lt;/li&gt;
&lt;li&gt;\w digunakan untuk Alphanumeric sama dengan [a-zA-Z0-9]&lt;/li&gt;
&lt;li&gt;\W digunakan untuk non-Alphanumeric, sama dengan [^a-zA-Z0-9]&lt;/li&gt;
&lt;/ul&gt;
Jika kita implementasikan kedalam program, misalnya untuk mencari 
semua string yang hanya berupa alpha numeric, kita dapat menggunakan 
preg_match_all() dan Sequences \w, seperti contoh&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_56135&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;ab-ce*fg@ hi &amp;amp; jkl(mnopqr)stu+vw?x yz0&amp;gt;1234&amp;lt;567890&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;/[\w]/&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$string&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;[0] &lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;)&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;{&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;echo&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$value&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Jika kita jalankan, maka semua karakter yang termasuk dalam 
Alphanumeric akan tampil, karena kita memberikan Sequences \w dalam 
regex, berbeda jika kita memberikan Sequences \W maka yang tampil adalah
 semua karakter yang bukan Alphanumeric, untuk penggunaan Sequences yang
 lain juga sama, tergntung fungsinya saja&lt;br /&gt;
&lt;h3&gt;

Capturing Text Inside HTML Tags&lt;/h3&gt;
skerang kita akan mencoba menggunakan regex dalam html, kita akan 
mencoba mengambil beberapa string berdasarkan tag html, untuk penjelsan 
dari masing-masing regex saya rasa sudah cukup jelas dari awal sampai 
akhir, di bagian ini kita akan mencoba menggabungkannya menjadi satu&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_444403&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;file_get_contents&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;&lt;a href=&quot;http://www.contoh.org/example.html&quot;&gt;http://www.contoh.org/example.html&lt;/a&gt;&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;@&amp;lt;h([1-6])&amp;gt;(.+?)&amp;lt;/h\1&amp;gt;@is&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;[2] &lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$text&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&quot;Heading: $text \n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Program di atas jika di jalankan akang menampilkan semua string yang 
berada dalam tag h1 sampai h6, untuk hasilnya teman-teman bisa 
mencobanya dengan mengcapture subuah halaman web dan melihat hasilnya&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_329923&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;file_get_contents&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;&lt;a href=&quot;http://www.contoh.org/example.html&quot;&gt;http://www.contoh.org/example.html&lt;/a&gt;&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;@&amp;lt;(strong|em)&amp;gt;(.+?)&amp;lt;/\1&amp;gt;@is&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php keyword&quot;&gt;foreach&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$matches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;[2] &lt;/code&gt;&lt;code class=&quot;php keyword&quot;&gt;as&lt;/code&gt; &lt;code class=&quot;php variable&quot;&gt;$text&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;) {&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php spaces&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/code&gt;&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&quot;Text: $text \n&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;}&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Program di atas akan menampilkan semua string yang mempunyai attribut
 seperti strong, atau em, teman-teman bisa menambahkan regex yang lain, 
seperti i untuk italic, atau b untuk bold&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_367497&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
8&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
9&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &#39;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;icon&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/icon.gif&quot;&gt;http://www.example.com/icon.gif&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;prev&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/prev.xml&quot;&gt;http://www.example.com/prev.xml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;next&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/next.xml&quot;&gt;http://www.example.com/next.xml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&#39;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;/rel=&quot;(prev|next)&quot; href=&quot;([^&quot;]*?)&quot;/&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$bothMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;/rel=&quot;(?:prev|next)&quot; href=&quot;([^&quot;]*?)&quot;/&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$linkMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;$bothMatches is: &#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;; var_dump(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$bothMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number8 index7 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;$linkMatches is: &#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;; var_dump(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$linkMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number9 index8 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
4&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
5&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
6&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
7&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;?php&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;= &#39;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;icon&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/icon.gif&quot;&gt;http://www.example.com/icon.gif&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;prev&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;title=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;Previous&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/prev.xml&quot;&gt;http://www.example.com/prev.xml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number4 index3 alt1&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;&amp;lt;link rel=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;next&quot;&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;href=&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;&lt;a href=&quot;http://www.example.com/next.xml&quot;&gt;http://www.example.com/next.xml&lt;/a&gt;&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;/&amp;gt;&#39;;&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number5 index4 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;preg_match_all(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;/rel=&quot;(?:prev|next)&quot;(?: title=&quot;[^&quot;]+?&quot;)? href=&quot;([^&quot;]*?)&quot;/&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$html&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;, &lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$linkMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number6 index5 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php string&quot;&gt;&#39;$bothMatches is: &#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;; var_dump(&lt;/code&gt;&lt;code class=&quot;php variable&quot;&gt;$linkMatches&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number7 index6 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;?&amp;gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/8606215170087048152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/php-regular-expression.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8606215170087048152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/8606215170087048152'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/php-regular-expression.html' title='PHP Regular Expression'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-611729436123394898</id><published>2012-06-01T16:24:00.004+07:00</published><updated>2012-06-01T16:25:53.058+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>FUNGSI STRING PHP</title><content type='html'>Dalam pembuatan program pasti kita sering berurusan dengan string 
atau teks, entah kita ingin mengambil hanya beberapa atau semua bagian 
dari teks tersebut atau langsung dimanipulasi hasilnya. Sekarang akan 
dicontohkan bagaimana memanipulasi huruf besar dan kecil pada string di 
PHP, contoh hutomo kaspar diganti menjadi Hutomo Kaspar.&lt;br /&gt;
&lt;span id=&quot;more-108&quot;&gt;&lt;/span&gt;Menggunakan ucfirst() atau ucwords() untuk membuat huruf depan dari kata atau kata – kata menjadi kapital:&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_20259&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php plain&quot;&gt;ucfirst(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;malang kota dingin dan asri&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;ucwords(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;batu kota wisata&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
Hasil:&lt;br /&gt;
Malang kota dingin dan asri&lt;br /&gt;
Batu Kota Wisata&lt;br /&gt;
Menggunakan strtolower() atau strtoupper untuk mengubah seluruh teks menjadi besar atau&lt;br /&gt;
kecil:&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_882357&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
3&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php functions&quot;&gt;strtoupper&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;halo apa kabar?&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php comments&quot;&gt;// Tag harus lowercase/kecil supaya sesuai dengan standar XHTML.&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number3 index2 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php functions&quot;&gt;strtolower&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;&amp;lt;A HREF=&quot;elang.php&quot;&amp;gt;elang&amp;lt;/A&amp;gt;&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
hasil:&lt;br /&gt;
HALO APA KABAR!&lt;br /&gt;
&amp;lt;a href=”elang.php”&amp;gt;elang&amp;lt;/a&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Gunakan ucfirst() untuk membuat huruf pertama menjadi kapital:
&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_203397&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;ucfirst(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;sungguh ria&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;ucfirst(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;7 kaspar&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
hasil:&lt;br /&gt;
Sungguh ria&lt;br /&gt;
7 kaspar&lt;br /&gt;
&lt;br /&gt;
Perhatikan pada hasil kedua hasilnya bukan “7 Kaspar”&lt;br /&gt;
Gunakan ucwords() untuk membuat huruf pada setiap kata menjadi kapital:&lt;br /&gt;
Use ucwords( ) to capitalize the first character of each word in a string:&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;syntaxhighlighter  php&quot; id=&quot;highlighter_65215&quot;&gt;
&lt;table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;gutter&quot;&gt;&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
1&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
2&lt;/div&gt;
&lt;/td&gt;&lt;td class=&quot;code&quot;&gt;&lt;div class=&quot;container&quot;&gt;
&lt;div class=&quot;line number1 index0 alt2&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;ucwords(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&#39;7 kaspar&#39;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;div class=&quot;line number2 index1 alt1&quot;&gt;
&lt;code class=&quot;php functions&quot;&gt;print&lt;/code&gt; &lt;code class=&quot;php plain&quot;&gt;ucwords(&lt;/code&gt;&lt;code class=&quot;php string&quot;&gt;&quot;bintang tiga printing malang&quot;&lt;/code&gt;&lt;code class=&quot;php plain&quot;&gt;);&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
hasil:&lt;br /&gt;
7 Kaspar&lt;br /&gt;
Bintang Tiga Printing Malang&lt;br /&gt;
&lt;br /&gt;
Untuk ucwords(), kata adalah karakter bukan kosong yang berurutan yang tampil setelah karakter kosong.&lt;br /&gt;
ucfirst() dan ucwords() tidak mengubah huruf yang bukan huruf pertama.&lt;br /&gt;
Fungsi strtolower() dan strtoupper() bekerja pada seluruh string, 
tidak hanya pada karakter individual. Semua karakter alfabet akan dibuah
 menjadi kecil oleh strtolower() atau menjadi besar oleh strtoupper()</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/611729436123394898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-string-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/611729436123394898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/611729436123394898'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-string-php.html' title='FUNGSI STRING PHP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-3622952507753939795</id><published>2012-06-01T16:19:00.001+07:00</published><updated>2012-06-01T16:20:10.625+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="PHP"/><title type='text'>BEBERAPA FUNGSI PHP</title><content type='html'>&lt;table class=&quot;contentpaneopen&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;contentheading&quot; width=&quot;100%&quot;&gt;&lt;a class=&quot;contentpagetitle&quot; href=&quot;http://agiptek.com/index.php/php/114-beberapa-fungsi-pengolah-string.html&quot;&gt;Beberapa Fungsi Pengolah String&lt;/a&gt;
   &lt;/td&gt;
      &lt;td align=&quot;right&quot; class=&quot;buttonheading&quot; width=&quot;100%&quot;&gt;&lt;a href=&quot;http://agiptek.com/index.php/php/114-beberapa-fungsi-pengolah-string.pdf&quot; rel=&quot;nofollow&quot; title=&quot;PDF&quot;&gt;&lt;img alt=&quot;PDF&quot; src=&quot;http://agiptek.com/images/M_images/pdf_button.png&quot; /&gt;&lt;/a&gt;  &lt;/td&gt;
  
    &lt;td align=&quot;right&quot; class=&quot;buttonheading&quot; width=&quot;100%&quot;&gt;&lt;a href=&quot;http://agiptek.com/index.php/php/114-beberapa-fungsi-pengolah-string.html?tmpl=component&amp;amp;print=1&amp;amp;layout=default&amp;amp;page=&quot; rel=&quot;nofollow&quot; title=&quot;Print&quot;&gt;&lt;img alt=&quot;Print&quot; src=&quot;http://agiptek.com/images/M_images/printButton.png&quot; /&gt;&lt;/a&gt;  &lt;/td&gt;
  
    &lt;td align=&quot;right&quot; class=&quot;buttonheading&quot; width=&quot;100%&quot;&gt;&lt;a href=&quot;http://agiptek.com/index.php/component/mailto/?tmpl=component&amp;amp;link=aHR0cDovL2FnaXB0ZWsuY29tL2luZGV4LnBocC9waHAvMTE0LWJlYmVyYXBhLWZ1bmdzaS1wZW5nb2xhaC1zdHJpbmcuaHRtbA%3D%3D&quot; title=&quot;E-mail&quot;&gt;&lt;img alt=&quot;E-mail&quot; src=&quot;http://agiptek.com/images/M_images/emailButton.png&quot; /&gt;&lt;/a&gt;  &lt;/td&gt;
     &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table class=&quot;contentpaneopen&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;td&gt;
       &lt;a href=&quot;http://agiptek.com/index.php/pemograman.html&quot;&gt;      Pemograman       &lt;/a&gt;            -      
      
       &lt;a href=&quot;http://agiptek.com/index.php/php.html&quot;&gt;      PHP       &lt;/a&gt;     
   &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign=&quot;top&quot;&gt;&lt;b&gt;strlen()&lt;/b&gt;&lt;br /&gt;
Digunakan untuk menghitung jumlah karakter dalam suatu variable, syantax-nya sebagai berikut : strlen($namavariable)&lt;br /&gt;
contoh:&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat=&quot;Belajar PHP&quot;;&lt;br /&gt;$jumlah=strlen($kalimat);&lt;br /&gt;print &quot;variable string \$kalimat=$kalimat &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;Kalimat &#39;$kalimat&#39; diatas jumlah karakternya adalah $jumlah&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;strpos()&lt;/b&gt;&lt;br /&gt;
Berguna untuk mengetahui posisi suatu 
karakter pada sebuah variable string, Anda bisa menuliskannya dengan 
syntax berikut : strpos($namavariable_string, $karakter)&lt;br /&gt;
contoh:&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat=&quot;Pemograman PHP&quot;;&lt;br /&gt;$karakter=&quot;m&quot;;&lt;br /&gt;$posisi=strpos($kalimat,$karakter);&lt;br /&gt;&lt;br /&gt;print &quot;Karakter &#39;$karakter&#39; berada pada posisi ke $posisi dalam kalimat &#39;$kalimat&#39; &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Fungsi untuk merubah huruf kapital&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Untuk merubah huruf pada variable string menjadi besar semua, Anda dapat menggunakan fungsi: strtoupper(&quot;datastring)&lt;br /&gt;
Sedangkan unuk mengubah menjadi huruf kecil semua dapat mengunakan fungsi : strtolower(&quot;datastring&quot;)&lt;br /&gt;
contoh&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat=&quot;Juara liga Indonesia 2006 adalah persik Kediri&quot;;&lt;br /&gt;print &quot;Kalimat awal adalah : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;$kalimat &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$ubah1=strtoupper($kalimat);&lt;br /&gt;print &quot;Kalimat diatas diubah menjadi huruf besar semua menjadi :&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;$ubah1 &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$ubah2 = strtolower($kalimat);&lt;br /&gt;print &quot;Kalimat diatas diubah menjadi huruf kecil semua menjadi : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;$ubah2 &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Jika Anda ingin merubah huruf peratama saja dalam suatu string maka bisa menggunakan fungsi berikut : ucfirst(&quot;data_string&quot;)&lt;br /&gt;
Untuk merubah huruf pertama saja dalam suatu kata dalam suatu string dapat menggunakan fungsi berikut : ucwords(&quot;data_string&quot;)&lt;br /&gt;
contoh&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat= &quot;belajar pemograman web dengan PHP&quot;;&lt;br /&gt;print &quot;Kalimat awal adalah &#39;$kalimat&#39; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$ubah1 =ucfirst($kalimat);&lt;br /&gt;print &quot;Setelah dirubah kapital huruf awalnya saja menjadi : &amp;lt;br&amp;gt; &quot;;&lt;br /&gt;print $ubah1 .&quot;&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$ubah2 = ucwords($kalimat);&lt;br /&gt;print &quot;Setelah dirubah menjadi kapital perkata menjadi : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print $ubah2 ;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Cara menghilangkan spasi dalam variable string&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Jika Anda ingin mengubah posisi spasi pada suatu variable string, Anda dapat menggunakan fungsi-fungis berikut&lt;br /&gt;
1. rtrim(&quot;data_string&quot;), untuk menghilangkan spasi yang ada di kanan string&lt;br /&gt;
2. ltrim(&quot;data_string&quot;), untuk menghilangkan spasi yang ada di kiri string&lt;br /&gt;
3. trim((&quot;data_string&quot;), untuk menghilangkan spasi yang ada di kanan dan kiri string&lt;br /&gt;
&lt;br /&gt;
Contoh penggunaan fungsi-fungsi diatas adalah sebagai berikut&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kata=&quot; Program PHP &quot;; // Perhatikan pada bagian awal dan akhir mengandung spasi satu ketuk&lt;br /&gt;print &quot;Kata &#39;$kata&#39; dengan spasi didepan dan dibelakang &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$hilang1=ltrim($kata);&lt;br /&gt;print &quot;Dihilangkan spasi didepan menjadi : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;&#39;$hilang1&#39; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$hilang2=rtrim($kata);&lt;br /&gt;print &quot;Dilihlangkan spasi dibelakang menjadi : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;&#39;$hilang2&#39; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;$hilang3=trim($kata);&lt;br /&gt;print &quot;Dilihlangkan spasi didepan dan dibelakang menjadi : &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;&#39;$hilang3&#39; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;text-decoration: underline;&quot;&gt;&lt;b&gt;Cara merubah variable string menjadi variable string baru yang diinginkan&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Gunakan fungsi substr() untuk merubah variable string sesuai keinginan Anda&lt;br /&gt;
syntax-nya &lt;b&gt;substr(&quot;data_string&quot;, posisi_awal, banyaknya_karakter)&lt;/b&gt;&lt;br /&gt;
Keterangan paramater dalam syntax substr():&lt;br /&gt;
data_string = adalah string kata atau kalimat atau karakter apapun berupa string yang ingin Anda rubah&lt;br /&gt;
posisi_awal&amp;nbsp;&amp;nbsp;&amp;nbsp; = adalah angka(bukan huruf) yang menunjukkan pada posisi keberapa Anda ingin merubah string&lt;br /&gt;
banyaknya_karakter = adalah angka(bukan huruf) yang menunjukkan banyaknya karakter yang ingin Anda rubah&lt;br /&gt;
contoh:&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kata=&quot;abcdefgh&quot;;&lt;br /&gt;print &quot;Variable \$kata = &#39;$kata&#39; dirubah menjadi string baru sebagai berikut : &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;echo substr($kata, 2) . &quot;&amp;nbsp; --&amp;gt; menggunakan fungsi substr(\$kata, 2) &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;echo substr($kata, 3,2) . &quot;&amp;nbsp; --&amp;gt; menggunakan fungsi substr(\$kata, 3,2) &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;echo substr($kata, 0,6) . &quot;&amp;nbsp; --&amp;gt; menggunakan fungsi substr(\$kata, 0,6) &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;echo substr($kata, -3,2) . &quot;&amp;nbsp; --&amp;gt; menggunakan fungsi substr(\$kata, -3,2) &amp;lt;br&amp;gt;&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Fungsi substring_count()&lt;/b&gt;&lt;br /&gt;
Berguna untuk menghitung
 jumlah kata(atau beberapa karakter) dalam sebuah string, syntax-nya 
sebagai berikut : substr_count(&quot;data_string&quot;, &quot;karakter_yg_dicari&quot;)&lt;br /&gt;
untuk lebih jelasnya perhatikan contoh berikut ini :&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat = &quot;PHP merupakan bahasa pemograman web dinamis. Bahasa PHP cukup mudah dipelajari, dan PHP free&quot;;&lt;br /&gt;$jumlah&amp;nbsp;&amp;nbsp;&amp;nbsp; = substr_count($kalimat, &quot;PHP&quot;);&lt;br /&gt;print &quot;Kalimat berikut ini &amp;lt;br&amp;gt; &#39;$kalimat&#39; &amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;print &quot;Jumlah kata &#39;PHP&#39; dalam kalimat diatas adalah : $jumlah&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;untuk tambah&amp;nbsp; lebih jelasnya lagi perhatikan contoh berikut ini:&lt;i&gt;&lt;br /&gt;&amp;lt;?php&lt;br /&gt;$kata2=array(&quot;ex&quot;,&quot;te&quot;,&quot;xt&quot;,&quot;ek&quot;);&lt;br /&gt;$lihat= &quot;text text text text text text text text&quot;;&lt;br /&gt;foreach($kata2 as $kw){&lt;br /&gt; echo &quot;Kata $kw terlihat &quot;. substr_count($lihat,$kw) . &quot;&amp;lt;br&amp;gt;&quot;;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Membuat String Berulang&lt;/b&gt;&lt;br /&gt;
Untuk membuat string berulang, Anda bisa menggunakan fungsi berikut :str_repeat(&quot;yang_akan_ulang&quot;, banyaknya_pengulangan)&lt;br /&gt;
Contoh :&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$ulang = str_repeat(&quot;selamat&quot;, 4);&lt;br /&gt;print &quot;Anda telah berhasil belajar PHP, $ulang&quot;;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;b&gt;Mengganti Bagian Dari String&lt;/b&gt;&lt;br /&gt;
Untuk mamnipulasi 
data string kadang Anda perlu untu mengganti bagian tertentu dari string
 dengan nilai string lainnya. Anda dapat menggunakan fungsi berikut : 
str_replace(&quot;yg_diganti&quot;, &quot;pengganti&quot;, &quot;kalimat&quot;)&lt;br /&gt;
parameter yg_diganti adalah string yang akan digantikan oleh string yang menggantikan&lt;br /&gt;
parameter pengganti adalah string yang akan menggantikan string yang digantikan&lt;br /&gt;
parameter kalimat adalah string awal yang berisi kalimat asli yang nantinya akan digantikan&lt;br /&gt;
contoh:&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kata1=&quot;Belajar PHP sangat susah yaaa !&quot;;&lt;br /&gt;$ubah= str_replace(&quot;susah&quot;, &quot;mudah&quot;, $kata1);&lt;br /&gt;print &quot;Kalimat &#39;$kata1&#39; &amp;lt;br&amp;gt;akan diganti menjadi : &amp;lt;br&amp;gt; &quot;;&lt;br /&gt;print $ubah;&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Memecah String&lt;/b&gt;&lt;br /&gt;
String
 dapat dipecah menjadi beberapa bagian, untuk memecah string perkata 
Anda dapat menggukanan fungsi berikut : strtok(&quot;string_yg_akan_dipecah&quot;,
 &quot;karakter_pemisah&quot;)&lt;br /&gt;
parameter karakter_pemisah bisa diisi dengan spasi kosong atau karakter apapun&lt;br /&gt;
contoh&lt;br /&gt;
&lt;i&gt;&amp;lt;?php&lt;br /&gt;$kalimat = &quot;di wwww.agiptek.com ada tutorial PHP yang cukup lengkap untuk jadi rujukan bagi pemula programmer PHP&quot;;&lt;br /&gt;$pecah&amp;nbsp;&amp;nbsp;&amp;nbsp; = strtok($kalimat, &quot; &quot;);&lt;br /&gt;while ($pecah){&lt;br /&gt; print &quot;$pecah &amp;lt;br&amp;gt;&quot;;&lt;br /&gt; $pecah = strtok(&quot; &quot;);&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/3622952507753939795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/beberapa-fungsi-php.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3622952507753939795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/3622952507753939795'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/beberapa-fungsi-php.html' title='BEBERAPA FUNGSI PHP'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5364592784852337392</id><published>2012-06-01T16:17:00.002+07:00</published><updated>2012-06-01T16:17:58.241+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MYSQL"/><title type='text'>FUNSI SQL 2</title><content type='html'>Berikut ini merupakan fungsi-fungsi yang digunakan dalam manipulasi string:&lt;br /&gt;

&lt;ul&gt;
&lt;li&gt;||&lt;br /&gt;
Menggabungkan dua string (operasi concat).&lt;/li&gt;
&lt;li&gt; ASCII&lt;br /&gt;
Mengembalikan nilai ASCII suatu karakter.&lt;/li&gt;
&lt;li&gt; CHR&lt;br /&gt;
Mengembalikan karakter suatu nilai ASCII.&lt;/li&gt;
&lt;li&gt; CONCAT&lt;br /&gt;
Sama fungsinya dengan ||.&lt;/li&gt;
&lt;li&gt; INITCAP&lt;br /&gt;
Mengubah huruf awal tiap kata menjadi huruf besar.&lt;/li&gt;
&lt;li&gt; INSTR&lt;br /&gt;
Mendapatkan posisi karakter dalam suatu string.&lt;/li&gt;
&lt;li&gt; LENGHT&lt;br /&gt;
Mendapatkan panjang suatu string.&lt;/li&gt;
&lt;li&gt; LOWER&lt;br /&gt;
Mengubah string menjadi huruf kecil.&lt;/li&gt;
&lt;li&gt; LPAD&lt;br /&gt;
Memampatkan string sampai panjang tertentu dengan manambahkan karakter di sebelah kiri.&lt;/li&gt;
&lt;li&gt; LTRIM&lt;br /&gt;
Melakukan trim terhadap karakter tertentu di sebelah kiri string.&lt;/li&gt;
&lt;li&gt; NLS_INITCAP&lt;br /&gt;
Melakukan fungsi INITCAP berdasarkan nilai Natural Language Support (NLS).&lt;/li&gt;
&lt;li&gt; NLS_LOWER&lt;br /&gt;
Melakukan fungsi LOWER berdasarkan nilai Natural Language Support (NLS).&lt;/li&gt;
&lt;li&gt; NLS_UPPER&lt;br /&gt;
Melakukan fungsi UPPER berdasarkan nilai Natural Language Support (NLS).&lt;/li&gt;
&lt;li&gt; NLSSORT&lt;br /&gt;
Melakukan fungsi SORT berdasarkan nilai Natural Language Support (NLS).&lt;/li&gt;
&lt;li&gt; REGEXP_INSTR, REGEXP_REPLACE, dan REGEXP_SUBSTR.&lt;/li&gt;
&lt;li&gt; RPAD&lt;br /&gt;
Memampatkan string sampai panjang tertentu dengan manambahkan karakter di sebelah kanan.&lt;/li&gt;
&lt;li&gt; RTRIM&lt;br /&gt;
Melakukan trim terhadap karakter tertentu di sebelah kanan string.&lt;/li&gt;
&lt;li&gt; SOUNDEX&lt;br /&gt;
Mencari kata yang memiliki bunyi sama (mirip operator LIKE).&lt;/li&gt;
&lt;li&gt; SUBSTR&lt;br /&gt;
Mengambil string dari suatu string.&lt;/li&gt;
&lt;li&gt; TREAT&lt;br /&gt;
Mengubah tipe dari suatu ekspresi.&lt;/li&gt;
&lt;li&gt; TRIM&lt;br /&gt;
Melakukan trim terhadap karakter tertentu di sebelah kiri dan kanan string.&lt;/li&gt;
&lt;li&gt; UPPER&lt;br /&gt;
Mengubah string menjadi huruf besar.&lt;/li&gt;
&lt;/ul&gt;
Format penggunaan fungsi ini adalah NAMA_FUNGSI(string [, opsi])&lt;br /&gt;

Beberapa fungsi memiliki opsi untuk digunakan. Setelah mengetahu 
fungsi apa saja yang digunakan untuk memanipulasi string sekarang 
saatnya kita mempraktekan fungsi-fungsi tersebut. Dalam praktek ini saya
 akan menggunakan tabel DUAL yang merupakan tabel semu dalam ORACLE.&lt;br /&gt;

&lt;strong&gt;LOWER&lt;/strong&gt;&lt;br /&gt;

Fungsi ini akan mengubah semua karakter dalam string menjadi huruf kecil.&lt;br /&gt;

&lt;blockquote&gt;
SELECT LOWER(‘ITFROMZEROTOHERO’) AS HASIL FROM dual&lt;/blockquote&gt;
&lt;strong&gt;CONCATNATION (|| dan CONCAT)&lt;/strong&gt;&lt;br /&gt;

Dua fungsi ini sama kegunaannya, yaitu untuk menggabungkan dua string menjadi satu.&lt;br /&gt;

&lt;blockquote&gt;
SELECT ‘IT’ || ‘ ‘ || ‘FROM’ || ‘ ‘ || ‘ZERO’ || ‘ ‘ || ‘TO’ || ‘ ‘ || ‘HERO’ AS hasil FROM dual&lt;/blockquote&gt;
&lt;strong&gt;RPAD&lt;/strong&gt;&lt;br /&gt;

Fungsi ini akan memamptkan string dengan menambahkan karakter di 
sebelah kanan. Bentuk umumnya adalah RPAD(string, length [, &#39;set&#39;]). 
Length merupakan panjang yanng diinginkan sedangkan ‘set’ adalah 
karakter yang digunakan untuk menambahkan string tersebut (bisa lebih 
dari 1 karakter).&lt;br /&gt;

&lt;blockquote&gt;
SELECT RPAD(’1234′, 8, ‘*’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;LPAD&lt;/strong&gt;&lt;br /&gt;

Sama seperti RPAD, hanya untuk LPAD penambahan karakter dilakukan di 
sebelah kiri (dapat digunakan untuk mencetak string menjadi rata kanan, 
defaultnya rata kiri)&lt;br /&gt;

&lt;blockquote&gt;
SELECT LPAD(’1234′, 8, ‘ ‘) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;LTRIM&lt;/strong&gt;&lt;br /&gt;

Fungsi ini akan melakukan trim (pembuangan) karakter di sebelah kiri 
string. Bentuk umumnya LTRIM(string [, &#39;set&#39;]). ‘set’ merupakan kumpulan
 karakter yang akan ditrim. Cara kerjanya adalah sebagai berikut: 
pertama Oracle akan mencari mulai dari sebelah kiri string apakah ada 
karakter yang cocok dengan ‘set’, apabila ada maka karakter tersebut 
akan dibuang, pencarian berhenti jika Oracle menemukan karakter yang 
tidak sesuai dengan ‘set’. Perlu diperhatikan proses trim yang terjadi 
berada pada tingkat karakter, bukan string. Jika kita bermaksud 
melakukan trim ‘ok’ pada string ‘odol’ maka string yang dihasilkan 
adalah ‘dol’. Ini disebabkan pada proses pencarian Oracle pertama kali 
menemukan huruf ‘o’ yang termasuk dalam ‘ok’ pada string ‘odol’, 
sehingga huruf tersebut dihilangkan, sedangkan pencarian berikutnya 
Oracle menemukan huruf ‘d’ dalam string ‘dol’ yang tidak ada dalam ‘ok’ 
sehingga proses berhenti. Jadi ingat, yang ditrim adalah karakter BUKAN 
kata. Urutan karakter dalam ‘set’ tidak berpengaruh dalam hasil, ‘ok’ 
dan ‘ko’ akan menghasilkan hal yang sama. Tetapi huruf kecil dan huruf 
besar berpengaruh, INGAT Oracle akan memperlakukan data secara case 
sensitif. Sehingga ‘ok’ dan ‘OK’ akan memberikan hasil yang berbeda. 
Apabila opsi ‘set’ tidak dipakai, yang ditrim adalah spasi.&lt;br /&gt;

&lt;blockquote&gt;
SELECT LTRIM(‘odol’, ‘ok’) FROM dual&lt;br /&gt;
SELECT LTRIM(‘odol’, ‘Ok’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;RTRIM&lt;/strong&gt;&lt;br /&gt;

Sama saja cara kerjanya seperti LTRIM hanya RTRIM akan melakukan trim di sebelah kanan string.&lt;br /&gt;

&lt;blockquote&gt;
SELECT RTRIM(‘itfromzerotohero’, ‘ok’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;TRIM&lt;/strong&gt;&lt;br /&gt;

Fungsi ini akan melakukan trim dikiri dan kanan string. Cara kerja 
sama seperti fungsi LTRIM dan RTRIM. Yang berbeda hanya bentuk umumnya 
dan karakter ‘set’ yang digunakan HANYA boleh satu.&lt;br /&gt;

&lt;blockquote&gt;
SELECT TRIM(‘i’ FROM ‘itfromzerotohero’) FROM dual&lt;/blockquote&gt;
Fungsi TRIM memiliki dua variasi, yaitu leading (mirip dengan LTRIM) serta trailing (mirip dengan RTRIM).&lt;br /&gt;

&lt;blockquote&gt;
SELECT TRIM(leading ‘i’ FROM ‘itfromzerotohero’) FROM dual&lt;br /&gt;
SELECT TRIM(trailing ‘o’ FROM ‘itfromzerotohero’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;LOWER, UPPER, INITCAP&lt;/strong&gt;&lt;br /&gt;

Fungsi LOWER akan mengubah string menjadi huruf kecil. Fungsi UPPER 
akan mengubah string menjadi huruf besar. Fungsi INITCAP akan mengubah 
huruf pertama setiap kata menjadi huruf besar.&lt;br /&gt;

&lt;blockquote&gt;
SELECT LOWER(‘itFromzeroToherO’) FROM dual&lt;br /&gt;
SELECT UPPER(‘itfromzerotohero’) FROM dual&lt;br /&gt;
SELECT INITCAP(‘it from zero to hero’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;LENGTH&lt;/strong&gt;&lt;br /&gt;

Fungsi LENGTH hanya menampilkan informasi berapa panjang string yang 
dimasukan. Fungsi ini biasanya dijadikan masukan bagi fungsi yang 
lainnya. Sebagai catatan, kita tidak dapat menggunakan fungsi ini untuk 
data bertipe LONG.&lt;br /&gt;

&lt;blockquote&gt;
SELECT LENGTH(‘it from zero to hero’) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;SUBSTR&lt;/strong&gt;&lt;br /&gt;

Mungkin inilah fungsi yang paling sering digunakan. Fungsi ini 
berguna jika kita ingin mengambil string dari dalam string. Bentuk 
umumnya adalah SUBSTR(string , start [, count]). start merupakan posisi 
awal pemotongan string, sedangkan opsi count akan menentukan berapa 
banyak karakter yang diambil mulai posisi start. Jika opsi tidak ditulis
 maka karakter akan diambil mulai dari start hingga karakter terakhir. 
Apabilai nilai start negatif, maka perhitungan posisi dilakukan mulai 
dari belakang. Perlu diperhatikan penggunaan start dengan bilangan 
negatif hanya diperuntukan untuk data bertipe VARCHAR2, JANGAN digunakan
 untuk data bertipe CHAR. Hal ini disebabkan Oracle selalu menambahkan 
spasi terhadap data bertipe CHAR jika panjangnya kurang dari panjang 
yang didefinisikan. Jika start bernilai negatif digunakan oleh SUBSTR 
dengan data bertipe CHAR maka perhitungannya dilakukan relatif dari 
akhir string hasil penambahan spasi oleh Oracle, bukan dari string 
aslinya.&lt;br /&gt;

&lt;blockquote&gt;
SELECT SUBSTR(’123456789′ , 3) FROM dual&lt;br /&gt;
SELECT SUBSTR(’123456789′ , 3, 4) FROM dual&lt;br /&gt;
SELECT SUBSTR(’123456789′ , -4) FROM dual&lt;br /&gt;
SELECT SUBSTR(’123456789′ , -4, 2) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;INSTR&lt;/strong&gt;&lt;br /&gt;

Fungsi ini akan mengembalikan posisi karakter yang dicari dalam suatu
 string. Sama seperti LENGTH, fungsi ini biasanya digunakan bersama 
dengan fungsi yang lain. Bentuk umumnya adalah INSTR(string, set [, 
start [, occurence]]). set merupakan karakter yang dicari posisinya, 
bisa lebih dari satu karakter. Posisi yang dikembalikan adalah posisi 
karakter yang pertama kali ditemukan. Misal kita ingin mengetahui posisi
 ‘el’ dalam string ‘hellohello’, maka yang dihasilkan adalah 2, karena 
pencarian akan menemukan huruf ‘e’ yang merupakan huruf pertama dari 
‘el’ pada string ‘hellohello’ di posisi dua.&lt;br /&gt;

&lt;blockquote&gt;
SELECT INSTR(‘itfromzerotohero’ , ‘o’) FROM dual&lt;/blockquote&gt;
Opsi start digunakan untuk menentukan awal mulai pencarian, defaulnya
 pada awal string. Sedangkan opsi kedua yaitu occurence digunakan untuk 
menentukan karakter keberapa yang cocok, defaultnya posisi yang 
dikembalikan adalah karakter pertama yang cocok.&lt;br /&gt;

&lt;blockquote&gt;
SELECT INSTR(‘itfromzerotohero’ , ‘o’, 5) FROM dual&lt;br /&gt;
SELECT INSTR(‘itfromzerotohero’ , ‘o’, 6) FROM dual&lt;br /&gt;
SELECT INSTR(‘hellohello’, ‘el’, 1, 2) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;ASCII, CHR&lt;/strong&gt;&lt;br /&gt;

Fungsi ASCII akan mengembalikan karakter dari nilai ascii yang 
dimasukan. Jika yang dimasukan adalah string maka hanya karakter pertama
 yang akan dihitung. Sedangkan CHR adalah kebalikannya.&lt;br /&gt;

&lt;blockquote&gt;
SELECT ASCII(‘A’) FROM dual&lt;br /&gt;
SELECT ASCII(‘Ada’) FROM dual&lt;br /&gt;
SELECT CHR(65) FROM dual&lt;/blockquote&gt;
&lt;strong&gt;SOUNDEX&lt;/strong&gt;&lt;br /&gt;

Fungsi ini kegunaannya lebih mirip dengan clausa WHERE dengan 
menggunakan operator LIKE. Sebagai contoh kita akan gunakan untuk 
menampilkan data pekerjaan yang mirip dengan ‘presiden’. SOUNDEX akan 
membuat asumsi bagaimana kombinasi huruf dieja dalam bahasa Inggris, dan
 kedua kata yang dibandingkan harus dimulai dengan huruf yang sama. 
SOUNDEX dapat dipakai untuk membandingkan data dari dua kolom yang 
sekiranya memiliki kemiripan bunyi.&lt;br /&gt;

&lt;blockquote&gt;
SELECT job_title FROM jobs WHERE SOUNDEX(job_title) = SOUNDEX(‘presiden’)&lt;/blockquote&gt;
Fungsi-fungsi di atas biasanya kita gunakan dalam melakukan filtering
 data, yaitu pada clausa WHERE. Contoh-contoh yang saya berikan selalu 
menggunakan tabel semu dual untuk menyederhanakan tutorial. Penggunaan 
umumnya data tidak langsung berupa literal string melainkan berupa data 
yang diambil dari kolom. Untuk itu literal string dapat digantikan 
dengan nama kolom, tentunya tanpa tanda petik satu. Silahkan 
bereksperimen dengan fungsi-fungsi manipulasi string ini, sebab tiap 
fungsi dapat dikombinasikan untuk mendapatkan hasil yang lebih banyak.</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5364592784852337392/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/funsi-sql-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5364592784852337392'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5364592784852337392'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/funsi-sql-2.html' title='FUNSI SQL 2'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-5634779895295786182</id><published>2012-06-01T16:15:00.002+07:00</published><updated>2012-06-01T16:15:20.674+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="MYSQL"/><title type='text'>FUNGSI-FUNGSI PADA MYSQL</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt; ASCI(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini digunakan untuk menghasilkan kode ASCII dari karakter pertama dalam suatu string x.&lt;br /&gt;Contoh: Select ASCII(&#39;n&#39;);&lt;br /&gt;Hasil: 110&lt;br /&gt;Contoh: Select ASCII(&#39;N&#39;);&lt;br /&gt;Hasil: 78&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt; CHAR(x, y, z, ...)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini dapat menghasilkan nilai string berdasarkan daftar kode ASCII yang dijadikan parameter dalam fungsi.&lt;br /&gt;Contoh: Select CHAR(65, 66, 40, 70);&lt;br /&gt;Hasil: AB(F&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt; CHARACTER_LENGTH, CHAR_LENGTH&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Pembahasan sama dengan LENGTH()&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt; COALESCE(ekspresi1, ekspresi2, ...)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini dapat menghasilkan data yang 
bukan NULL yang pertama kali dari daftar ekspresi yang menjadi argumen 
dalam parameter. Ekspresi dapat berupa data null, string, numerik 
ataupun tanggal.&lt;br /&gt;Contoh: Select COALESCE(NULL, &#39;Payah&#39;, 372);&lt;br /&gt;Hasil: Payah&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;CONCAT(x, y, z, ...)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini dapat menggabungkan beberapa 
string yang menjadi parameter. Tetapi jika ada nilai NULL dalam 
parameter string, maka hasil dari CONCAT adalah NULL.&lt;br /&gt;Contoh: Select CONCAT(&#39;Satu&#39;, &#39;2&#39;, &#39;Tiga&#39;);&lt;br /&gt;Hasil: Satu2Tiga&lt;br /&gt;Contoh: Select CONCAT(&#39;Satu&#39;, null, &#39;Tiga&#39;);&lt;br /&gt;Hasil: (NULL)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;DECODE(string_biner, string_ekspresi)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mengembalikan nilai string biner yang di
 enkripsi, string enkripsi yang digunakan harus sama dengan string yang 
digunakan pada saat mengenkripsi. Fungsi ini merupakan kebalikan dari 
fungsi ENCODE().&lt;br /&gt;Contoh: Select DECODE(&#39;Kambing&#39;, &#39;Mamalia&#39;);&lt;br /&gt;Hasil:  JF&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;ELT(x, a, b, c, ...)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menghasilkan string pada posisi x dari daftar argumen yang menjadi parameter a, b, c, ...&lt;br /&gt;Contoh: Select ELT(2, &#39;Panji&#39;, &#39;Dapur&#39;, &#39;Wempi&#39;);&lt;br /&gt;Hasil: Dapur&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;ENCODE(word, string_enkripsi)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini berguna untuk mengenkripsi 
suatu string word menggunakan kata sandi. Hasilnya adalah string biner 
yang telah dienkripsi.&lt;br /&gt;Contoh: Select ENCODE(&#39;Kambing&#39;, &#39;Mamalia&#39;), DECODE(ENCODE(&#39;Kambing&#39;, &#39;Mamalia&#39;), &#39;Mamalia&#39;);&lt;br /&gt;Hasil: 4&amp;gt;&#39;M2&lt;br /&gt;Hasil: Kambing&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;ENCRYPT(word[,seed])&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini juga berfungsi untuk 
mengenkripsikan suatu string dengan kata sandi seed dalam 2 huruf, 
menggunakan fungsi crypt Unix. Fungsi ini menghasilkan string yang 
terinkripsi dan NULL jika dilakukan pada system operasi yang tidak 
memiliki fungsy crypt seperti MS Windows.&lt;br /&gt;Contoh: Select ENCRYPT(&#39;Kambing&#39;, &#39;Ma&#39;);&lt;br /&gt;Hasil: (NULL) *di Windows XP&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;FIELD(x, a, b, ...)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini untuk menentukan posisi dari string x dalam daftar argumen a, b, ...&lt;br /&gt;Contoh: Select FIELD(&#39;Kambing&#39;, &#39;Kerbau&#39;, &#39;Sapi&#39;, &#39;Wempi&#39;, &#39;Kambing&#39;, &#39;Unta&#39;);&lt;br /&gt;Hasil: 4&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;FIND_IN_SET(x, stringlist)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mirip dengan fungsi FIELD(x, a, b, ...).
 Hanya saja stringlist merupakan kelompok string yang dicari dipisah 
menggunakan koma tanpa spasi.&lt;br /&gt;Contoh: Select FIND_IN_SET(&#39;Kambing&#39;, &#39;Kerbau,Sapi,Wempi,Kambing,Unta&#39;);&lt;br /&gt;Hasil: 4&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;INSERT(x, y, z,j)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini menghasilkan string x yang telah diganti isinya dengan string j mulai posisi ke y sebanyak z.&lt;br /&gt;Contoh: Select INSERT(&#39;Wemsatria&#39;, 4, 2, &#39;Pisang&#39;);&lt;br /&gt;Hasil: WemPisangtria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;INSTR(x, y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini merupakan kebalikan dari 
fungsi LOCATE(x, y) dan POSITION(x, y). Fungsi ini dapat menghasilkan 
nilai posisi string y di dalam string x.&lt;br /&gt;Contoh: Select INSTR(&#39;Wempi adalah te_no_net NoksPi Satria&#39;, &#39;te_no_net&#39;);&lt;br /&gt;Hasil: 14&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LCASE(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini berguna untuk menjadikan semua karakter dalam string x menjadi tulisan dalam huruf kecil semua (lowercase).&lt;br /&gt;Contoh: Select LCASE(&#39;Wempi Satria&#39;);&lt;br /&gt;Hasil: wempi satria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LEFT(x, y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini untuk mengambil sejumlah y karakter dari string x, mulai dari posisi awal.&lt;br /&gt;Contoh: Select LEFT(&#39;Wempi Satria&#39;, 5);&lt;br /&gt;Hasil: Wempi&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LENGTH(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Untuk mengetahui panjang string x, kita dapat menggunakan fungsi ini.&lt;br /&gt;Contoh: Select LENGTH(&#39;Wempi Satria&#39;);&lt;br /&gt;Hasil: 12&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LOCATE(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Untuk mengetahui posisi string x di dalam string y mulai dari posisi ke z.&lt;br /&gt;Contoh: Select LOCATE(&#39;m&#39;, &#39;Wempi&#39;, 2);&lt;br /&gt;Hasil: 3&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LOWER(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini sama denga fungsi LCASE(x).&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LPAD(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Digunakan untuk menambahkan string z kepada string x di sebelah kiri apabila panjang string x lebih kecil dari y)&lt;br /&gt;Contoh: Select LPAD(&#39;Satria&#39;, 12, &#39;We&#39;);&lt;br /&gt;Hasil: WeWeWeSatria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;LTRIM(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Berguna untuk menghilangkan spasi di sebelah kanan string x.&lt;br /&gt;Contoh: Select LTRIM(&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wempi Satria&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;Hasil: Wempi Satria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;MID(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mengambil string x sebanyak z dimulai dari posisi ke y.&lt;br /&gt;Contoh: Select MID(&#39;Wempi Satria&#39;, 4, 6);&lt;br /&gt;Hasil: pi Sat&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;OCTET_LENGTH()&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Lihat pembahasannya di fungsi LENGTH().&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;PASSWORD(password)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menghasilkan string password yang disandikan.&lt;br /&gt;Contoh: Select PASSWORD(&#39;Wempi&#39;);&lt;br /&gt;Hasi: *D4978643D6FD18E46D01128734C1081A976DE812&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;POSITION(x IN y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menghasilkan awal posisi dari string x yang pertama kali ditemukan dalam string y. Hasil 0 jika tidak ditemukan.&lt;br /&gt;Contoh: Select POSITION(&#39;Satria&#39; IN &#39;Wempi Satria&#39;);&lt;br /&gt;Hasil: 6&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;REPEAT(x, y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menghasilkan string x yang diulang sebayak y kali.&lt;br /&gt;Contoh: Select REPEAT(&#39;Wempi&#39;, 5);&lt;br /&gt;Hasil: WempiWempiWempiWempiWempi&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;REPLACE(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mengganti semua string y yang ditemukan dalam string x menggunakan string z.&lt;br /&gt;Contoh: Select REPLACE(&#39;Wempi Satria&#39;, &#39;i&#39;, &#39;e&#39;);&lt;br /&gt;Hasil: Wempe Satrea&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;REVERSE(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Membalikkan urutan penulisan string x.&lt;br /&gt;Contoh: Select REVERSE(&#39;Wempi Satria&#39;);&lt;br /&gt;Hasil: airtaS ipmeW&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;RIGHT(x, y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Mengambil y karakter dari string x dimulai dari posisi paling kanan (akhir).&lt;br /&gt;Contoh: Select RIGHT(&#39;Wempi Satria&#39;, 4);&lt;br /&gt;Hasil: tria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;RPAD(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menambahkan string z di sebelah kanan string x jika panjang string x lebih kecil dari y.&lt;br /&gt;Contoh: Select RPAD(&#39;Wempi&#39;, 12, &#39;Sat&#39;);&lt;br /&gt;Hasil: WempiSatSatS&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;RTRIM(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Membuang semua spasi yang ada di sebelah kanan string x.&lt;br /&gt;Contoh: Select RTRIM(&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wempi Satria&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;Hasil: &amp;nbsp;&amp;nbsp;&amp;nbsp; Wempi Satria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;SOUNDEX(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Menghasilkan sebuah string soundex dari string x.&lt;br /&gt;Contoh: Select SOUNDEX(&#39;Wempi Satria&#39;);&lt;br /&gt;Hasil W51236&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;SPACE(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Membuat string spasi sebanyak x.&lt;br /&gt;Contoh: Select SPACE(10);&lt;br /&gt;Hasil: &quot; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &quot;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;STRCMP(string1, string2)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Digunakan untuk menmbanding 2 buah string, jika jumlahnya sama akan diberi nilai 0, jika string1  string2 akan diberi nilai 1.&lt;br /&gt;Contoh: Select STRCMP(&#39;Wempi Satria&#39;, &#39;wempi satria&#39;);&lt;br /&gt;Hasil: 0&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;SUBSTRING_INDEX(x, y, z)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Digunakan untuk mendapatkan semua string
 x, setelah string y sebanyak z kali ditemukan. Jika z bernilai positif 
maka pointer bergerak dari kiri ke kanan dan sebaliknya.&lt;br /&gt;Contoh: Select SUBSTRING_INDEX(&#39;Wempi Satria&#39;, &#39;i&#39;, 1);&lt;br /&gt;Hasil: Wemp&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;TRIM([[BOTH or LEADING or TRAILING][x]FROM]y)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
LEADING digunakan untuk membuang string x
 dari depan string y. TRAILING digunakan untuk membuang string x dari 
belakang string y. BOTH digunakan untuk membuang string x di depan dan 
belakang string y.&lt;br /&gt;Contoh: Select TRIM(&#39;Wempi Satria&#39;); Select 
TRIM(LEADING &#39;Wempi&#39; FROM &#39;Wempi Satria&#39;); Select TRIM(BOTH &#39;Wempi&#39; FROM
 &#39;Wempi Satria Wempi&#39;);&lt;br /&gt;Hasil: Wempi Satria; Satria;&amp;nbsp; Satria&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;UCASE(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini dapat mengubah string x menjadi huruf kapital semua.&lt;br /&gt;Contoh: Select UCASE(&#39;Wempi Satria&#39;);&lt;br /&gt;Hasil: WEMPI SATRIA&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;UPPER(x)&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Fungsi ini sama dengan fungsi UCASE(x)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;strong&gt;------------------------------------------&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Selanjutnya  kita akan membahas tentang &lt;a href=&quot;http://wempi.nokspi.com/index.php/bimbingan/88-mysql/440-fungsi-mysql-date-time.html&quot; rel=&quot;lightbox&quot; title=&quot;Fungsi MySQL [Date - Time]&quot;&gt;&lt;strong&gt;Fungsi MySQL   [Date - Time]&lt;/strong&gt;&lt;/a&gt;.  Dan baca  juga  tulisan sebelumnya dengan judul&lt;strong&gt; &lt;a href=&quot;http://wempi.nokspi.com/index.php/bimbingan/88-mysql/410-fungsi-mysql-aritmetika-built-in.html&quot; rel=&quot;lightbox&quot; title=&quot;Fungsi MySQL [Aritmetika] - Built In&quot;&gt;Fungsi MySQL  [Aritmetika] - Built In&lt;/a&gt;&lt;/strong&gt;&lt;strong&gt;.&lt;/strong&gt;&lt;/div&gt;
&lt;div id=&quot;_mcePaste&quot; style=&quot;height: 1px; left: -10000px; overflow: hidden; position: absolute; text-align: justify; top: 331px; width: 1px;&quot;&gt;
Untitled
&lt;pre&gt;&lt;code&gt;&lt;span class=&quot;sql1-reservedword&quot;&gt;Select&lt;/span&gt;&lt;span class=&quot;sql1-space&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sql1-datatype&quot;&gt;CHAR&lt;/span&gt;&lt;span class=&quot;sql1-symbol&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sql1-number&quot;&gt;65&lt;/span&gt;&lt;span class=&quot;sql1-symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sql1-space&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sql1-number&quot;&gt;66&lt;/span&gt;&lt;span class=&quot;sql1-symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sql1-space&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sql1-number&quot;&gt;40&lt;/span&gt;&lt;span class=&quot;sql1-symbol&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sql1-space&quot;&gt; &lt;/span&gt;&lt;span class=&quot;sql1-number&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;sql1-symbol&quot;&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/5634779895295786182/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-fungsi-pada-mysql.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5634779895295786182'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/5634779895295786182'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-fungsi-pada-mysql.html' title='FUNGSI-FUNGSI PADA MYSQL'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-6487375964972025743</id><published>2012-06-01T16:05:00.001+07:00</published><updated>2012-06-01T16:15:47.796+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ORACLE"/><title type='text'>FUNGSI-FUNGS PADA SQL ORRACLE</title><content type='html'>&lt;u&gt;&lt;b&gt;4.1.2. CONCAT(column|expression1, column|expression2)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi CONCAT() digunakan untuk menggabungkan column atau expression.
 Fungsi ini sama dengan operator penggabungan (||). Perhatikan contoh 
berikut ini:&lt;br /&gt;
SELECT CONCAT(’Indra’, ‘ Armansyah’) “Name”&lt;br /&gt;
FROM dual;&lt;br /&gt;
SELECT CONCAT(first_name, CONCAT(’ ‘, last_name)) “Employee Name”&lt;br /&gt;
FROM employee;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.3. INITCAP(column|expression)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi INITCAP() digunakan untuk mengkonversi huruf awal yang 
terdapat pada suatu column atau expression menjadi huruf kapital (huruf 
besar). Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT INITCAP(’indra armansyah’) “Initcap”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Initcap&lt;br /&gt;
&lt;/u&gt;Indra Armansyah&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.4. LENGTH(column|expression)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi LENGTH() digunakan untuk menghitung panjang dari column atau expression. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT LENGTH(’Indra Armansyah’) “Length”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Length&lt;br /&gt;
&lt;/u&gt;15&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.5. LOWER(column|expression)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi LOWER() digunakan untuk mengkonversi nilai-nilai yang terdapat
 pada column atau expression menjadi huruf kecil. Perhatikan contoh 
berikut ini:&lt;br /&gt;
SELECT LOWER(’INDRA ARMANSYAH’) “Lowercase”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Lowercase&lt;br /&gt;
&lt;/u&gt;indra armansyah&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.6. UPPER(column|expression)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi UPPER() digunakan untuk mengubah untuk mengkonversi 
nilai-nilai yang terdapat pada column atau expression menjadi huruf 
besar. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT UPPER(’indra armansyah’) “Uppercase”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Uppercase&lt;br /&gt;
&lt;/u&gt;INDRA ARMANSYAH&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.7. NVL(column|expression1, column|expression2)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi NVL() digunakan untuk mengkonversi nilai null baik dari suatu 
column maupun expression menjadi sebuah nilai baru yang kita inginkan. 
Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT id, last_name “Name”, NVL(commission_pct,0) “Commission”&lt;br /&gt;
FROM employee;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.8. SUBSTR(column|expression, m, [n])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi SUBSTR() digunakan untuk mengambil &lt;i&gt;n&lt;/i&gt; karakter dari column|expression dimulai dari karakter ke-&lt;i&gt;m&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT SUBSTR(’Indra Armansyah’,1,5) “Substr”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Substr&lt;/u&gt;&lt;br /&gt;
Indra&lt;br /&gt;
SELECT SUBSTR(’Indra Armansyah’,-9) “Substr”&lt;br /&gt;
&lt;u&gt;Substr&lt;/u&gt;&lt;br /&gt;
Armansyah&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.1.9. REPLACE(column|expression1, expression2, expression3)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi REPLACE() digunakan untuk mengganti suatu string yang 
terkandung pada suatu string lain menjadi sebuah string baru yang kita 
inginkan. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT REPLACE(’20-JUL-2002′,’2002′,’1902′) “Replace”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Replace&lt;/u&gt;&lt;br /&gt;
20-JUL-1902&lt;br /&gt;
Pada contoh diatas kita mengganti string ‘2002′ yang terkandung di 
dalam ‘20-JUL-2002′ menjadi ‘1902′ sehingga hasilnya menjadi 
‘20-JUL-1902′.&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.2. Fungsi Angka&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.2.1. ROUND(column|expression[,n])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi ROUND digunakan untuk membulatkan nilai column atau expression sebanyak &lt;i&gt;n&lt;/i&gt; desimal di belakang koma. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT ROUND(19.74,1) “Round 1″, ROUND(19.75,1) “Round 2″&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Round 1&lt;/u&gt; &lt;u&gt;Round 2&lt;/u&gt;&lt;br /&gt;
19.7 19.8&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.2.2. TRUNC(column|expression[,n])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi TRUNC() digunakan untuk membulatkan kebawah atas nilai column atau expression sebanyak &lt;i&gt;n&lt;/i&gt; desimal di belakang koma. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT TRUNC(19.74,1) “Trunc 1″, TRUNC(19.75,1) “Trunc 2″&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Trunc 1&lt;/u&gt; &lt;u&gt;Trunc 2&lt;/u&gt;&lt;br /&gt;
19.7 19.7&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.2.3. MOD(m,n)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi MOD() digunakan untuk menampilkan sisa pembagian antara &lt;i&gt;m&lt;/i&gt; dan &lt;i&gt;n&lt;/i&gt;. Fungsi ini menghasilkan &lt;i&gt;m&lt;/i&gt; jika &lt;i&gt;n&lt;/i&gt; adalah 0. Perhatikan contoh berikut ini&lt;br /&gt;
SELECT MOD(3,2), MOD(3,0)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;MOD(3,2)&lt;/u&gt; &lt;u&gt;MOD(3,0)&lt;/u&gt;&lt;br /&gt;
1 3&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.2.4. POWER(m,n)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi POWER() digunakan untuk menampilkan hasil &lt;i&gt;m&lt;/i&gt; pangkat &lt;i&gt;n&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT POWER(3,2)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;POWER(3,2)&lt;/u&gt;&lt;br /&gt;
9&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3. Fungsi Tanggal&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.1. MONTHS_BETWEEN(date1, date2)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi MONTHS_BETWEEN() digunakan untuk menghitung selisih bulan antara &lt;i&gt;date1&lt;/i&gt; dan &lt;i&gt;date2&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT MONTHS_BETWEEN(sysdate,’01-OCT-02′)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.2. ADD_MONTHS(date, n)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi ADD_MONTHS() digunakan untuk menambahkan &lt;i&gt;n&lt;/i&gt; bulan terhadap &lt;i&gt;date&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT ADD_MONTHS(’01-OCT-02′,2)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.3. NEXT_DAY(date,’char’)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi NEXT_DAY() digunakan untuk mencari tanggal dari hari pertama (&lt;i&gt;char&lt;/i&gt;) setelah &lt;i&gt;date&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT NEXT_DAY(’01-OCT-02′,2)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.4. LAST_DAY(date)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi LAST_DAY() digunakan untuk mencari tanggal terakhir dari bulan &lt;i&gt;date&lt;/i&gt;. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT LAST_DAY(’01-OCT-01′)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;LAST_DAY(&lt;/u&gt;&lt;br /&gt;
31-OCT-01&lt;br /&gt;
Perhatikan bahwa tanggal terakhir dari bulan October adalah 31-OCT-01.&lt;br /&gt;
&lt;a href=&quot;http://hastinapura.tradepub.com/c/pubRD.mpl?sr=hm&amp;amp;_t=hm:&amp;amp;pc=orm&quot; target=&quot;_blank&quot;&gt;&lt;img alt=&quot;Oracle Magazine&quot; class=&quot;alignleft&quot; height=&quot;150&quot; src=&quot;http://img.tradepub.com/free/orm/images/ormc.gif&quot; style=&quot;float: left;&quot; width=&quot;114&quot; /&gt;&lt;/a&gt;&lt;i&gt;Oracle Magazine&lt;/i&gt;
 contains technology strategy articles, sample code, tips, Oracle and 
partner news, how to articles for developers and DBAs, and more. Oracle 
(NASDAQ: ORCL) is the world’s largest enterprise software company.&lt;br /&gt;
&lt;div align=&quot;left&quot;&gt;
For more information about Oracle, please visit their 
Web site at http://www.oracle.com. Oracle is a registered trademark of 
Oracle Corporation and/or its affiliates. Other names may be trademarks 
of their respective owners. &lt;i&gt;&lt;/i&gt;&lt;/div&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;i&gt;&lt;a href=&quot;http://hastinapura.tradepub.com/c/pubRD.mpl?sr=hm&amp;amp;_t=hm:&amp;amp;pc=orm&quot; target=&quot;_blank&quot;&gt;Get Free Oracle Magazine&lt;/a&gt;&lt;/i&gt;&lt;/div&gt;
&lt;u&gt;&lt;b&gt;4.3.5. ROUND(date[,’fmt’])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi ROUND() digunakan untuk membulatkan &lt;i&gt;date&lt;/i&gt;. Jika &lt;i&gt;fmt&lt;/i&gt; tidak disebutkan maka akan dibulatkan ke hari terdekat. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT ROUND(TO_DATE(’27-OCT-92′),’YEAR’) “Round Date”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Round Date&lt;/u&gt;&lt;br /&gt;
01-JAN-93&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.6. SYSDATE&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi SYSDATE digunakan untuk menampilkan tanggal dan jam sistem. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT SYSDATE “Today”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.3.7. TRUNC(date[,’fmt’])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi TRUNC() digunakan untuk membulatkan &lt;i&gt;date&lt;/i&gt;. Jika &lt;i&gt;fmt&lt;/i&gt; tidak disebutkan maka akan dibulatkan ke hari terdekat. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT TRUNC(TO_DATE(’27-OCT-92′),’YEAR’) “Trunc Date”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;Trunc Date&lt;/u&gt;&lt;br /&gt;
01-JAN-92&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.4. Fungsi Konversi&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.4.1. TO_CHAR(number|date[,’fmt’])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi TO_CHAR() digunakan untuk mengkonversi data bertipe number atau date menjadi karakter. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT TO_CHAR(sysdate,’DD MONTH YYYY’)&lt;br /&gt;
FROM dual;&lt;br /&gt;
Jika kita asumsikan bahwa tanggal sistem adalah 01-OCT-01 maka hasil query adalah sebagai berikut:&lt;br /&gt;
&lt;u&gt;TO_CHAR(SYSDATE,’&lt;/u&gt;&lt;br /&gt;
01 OCTOBER 2001&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.4.2. TO_DATE(char[,’fmt’])&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi TO_DATE() digunakan untuk mengkonversi data bertipe karakter menjadi tanggal. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT TO_DATE(’01-OCT-02′,’DD-MON-YY’)&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;TO_DATE(’&lt;/u&gt;&lt;br /&gt;
01-OCT-02&lt;br /&gt;
Fungsi TO_DATE berguna jika kita ingin menginputkan data atau mencari
 berdasarkan data bertipe tanggal, namun format tanggal yang kita miliki
 berbeda dengan format default yang ada (DD-MON-YY). Penjelasan lengkap 
dapat diikuti pada bagian Interpretasi Tanggal.&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.4.3. TO_NUMBER(char)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi TO_NUMBER() digunakan untuk mengkonversi data bertipe karakter menjadi angka. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT TO_NUMBER(’5′) * 5&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;TO_NUMBER(’5′)*5&lt;/u&gt;&lt;br /&gt;
25&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.5. Fungsi Lain&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.5.1. GREATEST(expr1[,expr2]…)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi GREATEST() digunakan untuk mencari nilai terbesar dari beberapa expression. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT GREATEST(’HARRY’,&#39;HARRIOT’,&#39;HAROLD’) “Greatest”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;GREAT&lt;/u&gt;&lt;br /&gt;
HARRY&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.5.2. LEAST(expr1[,expr2]…)&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi LEAST() digunakan untuk mencari nilai terkecil dari beberapa expression. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT LEAST(’HARRY’,&#39;HARRIOT’,&#39;HAROLD’) “Least”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;u&gt;LEAST&lt;/u&gt;&lt;br /&gt;
HAROLD&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.5.3. USER&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Fungsi USER digunakan untuk menampilkan nama user yang sedang terkoneksi dengan database Oracle. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT USER, UID&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 200px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;u&gt;USER&lt;/u&gt;&lt;/td&gt;
&lt;td&gt;&lt;u&gt;UID&lt;/u&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;INDRA&lt;/td&gt;
&lt;td&gt;2367&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;br /&gt;
&lt;u&gt;4.5.4. USERENV(option)&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Fungsi USERENV() digunakan untuk menampilkan environment pengguna. Perhatikan contoh berikut ini:&lt;br /&gt;
SELECT USERENV(’LANGUAGE’) “Language”, USERENV(’TERMINAL’) “Terminal”&lt;br /&gt;
FROM dual;&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 200px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;u&gt;Language&lt;/u&gt;&lt;/td&gt;
&lt;td&gt;&lt;u&gt;Terminal&lt;/u&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AMERICAN_AMERICA.WE8MSWIN1252&lt;/td&gt;
&lt;td&gt;HASTINAPURA&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;b&gt;&lt;br /&gt;
&lt;u&gt;4.5.5. VSIZE()&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
Fungsi VSIZE(expr) digunakan untuk menampilkan jumlah byte dalam representasi internal dari &lt;i&gt;expr&lt;/i&gt;.&lt;br /&gt;
SELECT last_name “Name”, VSIZE(last_name) “Bytes”&lt;br /&gt;
FROM employee;&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 200px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;u&gt;Name&lt;/u&gt;&lt;/td&gt;
&lt;td&gt;&lt;u&gt;Bytes&lt;/u&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Velasquez&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Ngao&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nagayama&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div align=&quot;left&quot;&gt;
&lt;u&gt;&lt;b&gt;&lt;br /&gt;
Interpretasi Tanggal&lt;/b&gt;&lt;/u&gt;&lt;/div&gt;
Kita perlu berhati-hati jika bekerja dengan data bertipe tanggal, 
karena Oracle menginterpretasikan tahun sesuai dengan tahun pada tanggal
 sistem.&lt;br /&gt;
&lt;table border=&quot;0&quot; style=&quot;width: 287px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td width=&quot;92&quot;&gt;&lt;u&gt;Data&lt;/u&gt;&lt;/td&gt;
&lt;td width=&quot;83&quot;&gt;&lt;u&gt;Tahun Sistem&lt;br /&gt;
&lt;/u&gt;&lt;/td&gt;
&lt;td width=&quot;98&quot;&gt;&lt;u&gt;Interpretasi&lt;/u&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;01-OCT-01&lt;/td&gt;
&lt;td&gt;&amp;gt;=2000&lt;/td&gt;
&lt;td&gt;01-OCT-2001&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;01-OCT-01&lt;/td&gt;
&lt;td&gt;&amp;lt; 2000&lt;/td&gt;
&lt;td&gt;01-OCT-1901&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Perhatikan contoh berikut:&lt;br /&gt;
CREATE TABLE tanggal( tanggal DATE );&lt;br /&gt;
Pastikan berapa sesungguhnya tahun sistem sekarang dengan menggunakan
 fungsi TO_CHAR. Kemudian satu data ke dalam tabel TANGGAL, tahun yang 
kita maksud disini adalah 1974, bukan 2074.&lt;br /&gt;
INSERT INTO tanggal VALUES(‘01-OCT-74′);&lt;br /&gt;
SELECT TO_CHAR(TANGGAL,’DD-MON-YYYY’)&lt;br /&gt;
FROM   coba;&lt;br /&gt;
&lt;u&gt;TANGGAL&lt;/u&gt;&lt;br /&gt;
01-OCT-2074&lt;br /&gt;
Oracle menginterpretasikan tahun 74 yang kita inputkan menjadi 2074 
bukannya 1974. Mengapa demikian? Perhatikan kembali penjelasan pada 
tabel mengenai interpretasi tanggal.&lt;br /&gt;
Kita dapat menggunakan dua alternatif pemecahan untuk mengatasi permasalahan ini:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Mengubah tanggal sistem dari sistem operasi sehingga memiliki tahun &amp;lt; 2000 (tidak disarankan)&lt;/li&gt;
&lt;li&gt;Menggunakan fungsi TO_DATE&lt;/li&gt;
&lt;/ol&gt;
Pada dasarnya kita harus memberitahukan kepada Oracle dengan jelas 
berapa sesungguhnya tahun yang kita maksud, 1974 atau 2074, agar data 
dapat diinterpretasikan dengan benar. Perhatikan perintah insert yang 
sudah dimodifikasi berikut:&lt;br /&gt;
INSERT INTO tanggal VALUES(TO_DATE(‘01-OCT-1974′,’DD-MON-YYYY’);&lt;br /&gt;
SELECT TO_CHAR(TANGGAL,’DD-MON-YYYY’)&lt;br /&gt;
FROM tanggal;&lt;br /&gt;
&lt;u&gt;TANGGAL&lt;/u&gt;&lt;br /&gt;
01-OCT-1974&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Format Tanggal&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
SCC atau CC : Abad.&lt;br /&gt;
YYYY atau SYYYY :    Tahun dalam empat digit.&lt;br /&gt;
YYY atau YY atau Y :    Tiga, dua, atau satu digit terakhir dari tahun.&lt;br /&gt;
Y,YYY :    Tahun dengan koma pada posisi tersebut.&lt;br /&gt;
SYEAR atau YEAR :    Tahun dalam ejaan.&lt;br /&gt;
Q                                   :    Kwartal dari tahun.&lt;br /&gt;
MM                                :    Bulan dalam dua digit.&lt;br /&gt;
MONTH                          :    Bulan dalam ejaan.&lt;br /&gt;
MON                              :    Bulan dalam ejaan tiga huruf.&lt;br /&gt;
RM                                 :    Bulan dalam angka romawi.&lt;br /&gt;
WW atau W                    :    Minggu ke sekian dalam tahun yang bersangkutan, dalam dua atau satu digit.&lt;br /&gt;
DDD atau DD atau D        :    Hari ke sekian dalam tahun, bulan atau minggu yang bersangkutan.&lt;br /&gt;
DAY                               :    Hari dalam ejaan.&lt;br /&gt;
DY                                 :    Hari dalam ejaan tiga huruf.&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Format Waktu&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
AM atau PM (A.M. atau P.M.)         :    Indikator meridian.&lt;br /&gt;
HH atau HH12 atau HH24               :    Jam kesekian dalam hari yang bersangkutan, jam(1 - 12), atau jam (0 - 23)&lt;br /&gt;
MI                                                 :    Menit (0 - 59).&lt;br /&gt;
SS                                                :    Detik (0 - 59).&lt;br /&gt;
SSSSS                                         :    Detik ke sekian setelah tengah malam (0 - 86399).&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Format Lain&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
/ . ,                               :    Memisahkan hasil konversi sesuai tampilan yang diinginkan.&lt;br /&gt;
” of the  ”                       :    Menambahkan karakter string ke dalam tampilan hasil konversi.&lt;br /&gt;
&lt;b&gt;&lt;u&gt;Akhiran&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;
TH                                :    Menampilkan urutan nomor (contoh, DDTH untuk 4 TH).&lt;br /&gt;
SP                               :    Nomor dalam ejaan (contoh, DDSP untuk FOUR)&lt;br /&gt;
SPTH atau THSP          :    Menampilkan urutan nomor dalam ejaan (contoh, DDSPTH untuk FOURTH).&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Format Angka&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
9             :    Posisi numerik (jumlah angka 9 menunjukkan 
maksimal panjang data yang dapat ditampilkan). Contoh 999999 untuk hasil
 1234&lt;br /&gt;
0             :    Menambahkan awalan 0. Contoh 099999 untuk hasil 01234&lt;br /&gt;
$             :    Menambahkan awalan dollar. Contoh $999999 untuk hasil $1234&lt;br /&gt;
L             :    Menambahkan simbol local currency. Contoh L999999 untuk hasil L1234&lt;br /&gt;
.             :    Menambahkan titik pada posisi tertentu. Contoh 999999.99 untuk hasil 1234.00&lt;br /&gt;
,             :    Menambahkan koma pada posisi tertentu. Contoh 999,999 untuk hasil 1,234&lt;br /&gt;
MI           :    Menambahkan tanda negatif di sebelah kanan angka. Contoh 999999MI&lt;br /&gt;
untuk hasil 1234-&lt;br /&gt;
PR          :    Contoh 999999PR untuk hasil &amp;lt;1234&amp;gt;&lt;br /&gt;
EEEE     :    Notasi untuk operasi scientific. Contoh 99.999EEEE untuk hasil 1,234E+03&lt;br /&gt;
V            :    Mengalikan dengan 10 n kali (n menunjukkanjumlah angka 9 setelah V). Contoh 9999V99 untuk hasil 123400&lt;br /&gt;
B            :    Menampilkan nilai nol sebagai blank. Contoh B9999,99 untuk hasil 1234,00&lt;br /&gt;
&lt;u&gt;&lt;b&gt;4.6. Latihan&lt;/b&gt;&lt;/u&gt;&lt;br /&gt;
Tampilkan nama lengkap pegawai dengan huruf kecil, inisial pegawai 
dengan huruf depan kapital, dan jabatan pegawai dengan huruf kapital, 
khusus untuk pegawai dengan jabatan vice president. Tampilkan nama 
lengkap pegawai dengan judul VP, inisial pegawai dengan judul USERID, 
dan jagatan pegawai dengan judul TITLE.&lt;br /&gt;
SELECT LOWER(first_name | | ‘ ‘ | | last_name) VP, INITCAP(userid) USERID, UPPER(title) TITLE&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE title LIKE ‘VP%’;&lt;br /&gt;
Tampilkan nama depan dan nama belakang pegawai yang memiliki nama belakang PATEL.&lt;br /&gt;
SELECT first_name, last_name&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE UPPER(last_name) = ‘PATEL’;&lt;br /&gt;
Tampilkan nama dan negara pelanggan dengan nilai kredit GOOD. 
Tampilkan nama dan negara pelanggan dalam satu kolom dipisahkan spasi, 
beri judul CUSTOMER.&lt;br /&gt;
SELECT CONCAT(name, country) CUSTOMER&lt;br /&gt;
FROM customer;&lt;br /&gt;
Tampilkan nama produk dan panjang dari nama produk tersebut untuk produk yang tiga huruf pertamanya adalah “Ace”.&lt;br /&gt;
SELECT name, LENGTH(name)&lt;br /&gt;
FROM product&lt;br /&gt;
WHERE SUBSTR(name,1,3) = ‘Ace’;&lt;br /&gt;
Tampilkan nama produk dan panjang dari nama produk tersebut untuk produk yang tiga huruf terakhirnya adalah “Bar”.&lt;br /&gt;
SELECT name, LENGTH(name)&lt;br /&gt;
FROM product&lt;br /&gt;
WHERE SUBSTR(name,-3) = ‘Bar’&lt;br /&gt;
Ketikkan perintah berikut ini dan amatilah hasilnya.&lt;br /&gt;
SELECT ROUND(45.923,2), ROUND(45.923,1), ROUND(45.923,0), ROUND(45.923,-1), ROUND(45.923,-2)&lt;br /&gt;
FROM SYS. DUAL;&lt;br /&gt;
Ketikkan perintah berikut ini dan amatilah hasilnya.&lt;br /&gt;
SELECT TRUNC(45.923,2), TRUNC(45.923,1), TRUNC(45.923,0), TRUNC(45.923,-1), TRUNC(45.923,-2)&lt;br /&gt;
FROM SYS. DUAL;&lt;br /&gt;
Tampilkan nama belakang, jabatan pegawai dan kode departemen dimana 
pegawai tersebut bekerja khusus untuk pegawai yang bekerja pada 
departemen dengan kode genap.&lt;br /&gt;
SELECT last_name, title, dept_id&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE MOD(dept_id,2) = 0;&lt;br /&gt;
Tampilkan tanggal sistem.&lt;br /&gt;
SELECT sysdate&lt;br /&gt;
FROM sys.dual;&lt;br /&gt;
Tampilkan nama belakang dan masa kerja pegawai yang bekerja pada 
departemen dengan kode 43, dengan ketentuan bahwa masa kerja adalah 
tanggal sejak pegawai tersebut bekerja hingga sekarang. Tampilkan masa 
kerja tersebut dalam hitungan minggu dan beri judul dengan WEEKS. 
Tampilkan urut berdasarkan nama belakang pegawai.&lt;br /&gt;
SELECT last_name, (SYSDATE - start_date) / 7&amp;nbsp; WEEKS&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE dept_id = 43;&lt;br /&gt;
Tampilkan kode pegawai, tanggal pegawai tersebut mulai bekerja, lama 
pegawai tersebut bekerja hingga sekarang dalam hitungan bulan dengan 
judul TENURE, dan enam bulan berikut sejak pegawai tersebut bekerja 
dengan judul REVIEW, khusus untuk pegawai dengan masa kerja hingga 
sekarang lebih dari 100 bulan.&lt;br /&gt;
SELECT id, start_date, MONTHS_BETWEEN(SYSDATE, start_date)&lt;br /&gt;
TENURE, ADD_MONTHS(start_date,6) REVIEW&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE MONTHS_BETWEEN(SYSDATE, start_date) &amp;gt; 100;&lt;br /&gt;
Tampilkan kode pegawai, tanggal pegawai tersebut mulai bekerja, hari 
Jum’at pertama setelah tanggal pegawai tersebut mulai bekerja, dan 
tanggal terakhir dari bulan pegawai tersebut mulai bekerja, khusus untuk
 pegawai yang memiliki kode genap.&lt;br /&gt;
SELECT id, start_date, NEXT_DAY(start_date,’FRIDAY’), LAST_DAY(start_date)&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE MOD(id,2) = 0;&lt;br /&gt;
Ketikkan perintah berikut ini dan amatilah hasilnya.&lt;br /&gt;
SELECT id, start_date,ROUND(start_date,’MONTH’) RM, 
TRUNC(start_date,’MONTH’) TM,ROUND(start_date,’YEAR’) RY, 
TRUNC(start_date,’YEAR’) TY&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE start_date LIKE ‘%91′;&lt;br /&gt;
Tampilkan nomor order dan tanggal order untuk semua order yang 
ditangani oleh sales representative dengan kode 11. Tampilkan tanggal 
order dengan format MM/YY dan beri judul ORDERED.&lt;br /&gt;
SELECT ID, TO_CHAR(date_ordered,’MM/YY’) ORDERED&lt;br /&gt;
FROM orders&lt;br /&gt;
WHERE sales_rep_id = 11;&lt;br /&gt;
Tampilkan nama belakang pegawai dan tanggal pegawai tersebut mulai 
bekerja. Untuk tanggal pegawai mulai bekerja tampilkan dengan format 
sehingga akan tampak seperti 7 of February 1991 dan beri judul HIREDATE.&lt;br /&gt;
COLUMN HIREDATE FORMAT A50&lt;br /&gt;
SELECT last_name, TO_CHAR(start_date,’fmDD “of” Month YYYY’)&lt;br /&gt;
HIREDATE&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE start_date LIKE ‘%91′;&lt;br /&gt;
Tampilkan kembali soal diatas dimana tanggal pegawai mulai bekerja 
akan tampak seperti Sevententh of February 1991 08:00:00 AM dan beri 
judul HIREDATE.&lt;br /&gt;
SELECT last_name, TO_CHAR(start_date,’fmDdspth “of” Month YYYY&lt;br /&gt;
fmHH:MI:SS AM’)&amp;nbsp; HIREDATE&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE start_date LIKE ‘%91′;&lt;br /&gt;
Tampilkan pesan yang mengindikasikan nomor dan total order, khusus 
untuk order yang dikirimkan pada tanggal 21 September 1992. Tampilkan 
dengan judul NOTE.&lt;br /&gt;
SELECT ‘Order ‘ | | TO_CHAR(id) | | ‘ was filled for a total of ‘ | | TO_CHAR(total,’fm$99,999,999′) NOTE&lt;br /&gt;
FROM orders&lt;br /&gt;
WHERE date_shipped = ‘21-SEP-92′;&lt;br /&gt;
Tampilkan nomor, total dan tanggal untuk order dengan tanggal 
September 7, 1992. Konversilah string tanggal pada soal ini menjadi 
format tanggal, sehingga dapat dilakukan pencarian terhadap data yang 
dimaksud.&lt;br /&gt;
SELECT id, total, date_ordered&lt;br /&gt;
FROM orders&lt;br /&gt;
WHERE date_ordered = TO_DATE(’7 September 1992′,’dd Month YYYY’);&lt;br /&gt;
Tampilkan gabungan nama belakang dan jabatan pegawai dengan judul 
Vice President, khusus untuk pegawai dengan jabatan vice president, 
dengan ketentuan nama belakang ditampilkan dengan huruf kapital.&amp;nbsp; 
Hilangkan karakter VP pada jabatan.&lt;br /&gt;
SELECT CONCAT(UPPER(last_name), SUBSTR(title,3)) “Vice President”&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE title LIKE ‘VP%’;&lt;br /&gt;
Tampilkan nama belakang dari pimpinan perusahaan, yaitu pegawai yang tidak memiliki atasan, sehingga akan tampak seperti:&lt;br /&gt;
BOSS&lt;br /&gt;
——————————-&lt;br /&gt;
Velasquez has no manager&lt;br /&gt;
SELECT last_name | | ‘ ‘ | | ‘has no manager’ BOSS&lt;br /&gt;
FROM employee&lt;br /&gt;
WHERE manager_id IS NULL;&lt;br /&gt;
Tampilkan tanggal dari hari Jum’at enam bulan&amp;nbsp; berikutnya setelah 
tanggal order. Hasilnya akan tampak seperti : Friday, March 12th, 1993. 
Tampilkan dengan judul New 6 Month Review, dan urutkan berdasarkan 
tanggal order.&lt;br /&gt;
SELECT TO_CHAR(NEXT_DAY(ADD_MONTHS(date_ordered,6), ‘FRIDAY’), ‘fmDay, Month ddth, YYYY’) “New 6 Month Review”&lt;br /&gt;
FROM orders&lt;br /&gt;
ORDER BY date_ordered;&lt;br /&gt;
Tampilkan nama belakang dan jabatan pegawai, sehingga tampak seperti berikut:&lt;br /&gt;
EMPLOYEE&lt;br /&gt;
—————————————————————-&lt;br /&gt;
Biri(Warehouse Manager)&lt;br /&gt;
Catchpole(Warehouse Manager)&lt;br /&gt;
……………………&lt;br /&gt;
SELECT last_name | | ‘(’ | | title | | ‘)’&amp;nbsp; EMPLOYEE&lt;br /&gt;
FROM employee&lt;br /&gt;
ORDER BY last_name;&lt;br /&gt;
Tampilkan nama belakang pegawai, tanggal pegawai tersebut mulai 
bekerja, tanggal peninjauan gaji pegawai yang merupakan hari Senin 
pertama setelah enam bulan seorang pegawai bekerja. Tampilkan tanggal 
peninjauan gaji dengan judul REVIEW dan dengan format seperti Eight of 
May 1992.&lt;br /&gt;
COLUMN REVIEW FORMAT A50&lt;br /&gt;
SELECT last_name,start_date, TO_CHAR(NEXT_DAY(ADD_MONTHS(start_date,6),&lt;br /&gt;
‘MONDAY’),’fmDdspth “of” Month YYYY’) REVIEW&lt;br /&gt;
FROM employee&lt;br /&gt;
ORDER BY start_date;&lt;br /&gt;
Tampilkan nama belakang pegawai, tanggal dan hari pegawai tersebut mulai bekerja.&lt;br /&gt;
COLUMN DAY FORMAT A10&lt;br /&gt;
SELECT last_name, start_date, TO_CHAR(start_date,’fmDAY’) DAY&lt;br /&gt;
FROM employee;&lt;br /&gt;
Tampilkan gabungan nama belakang, gaji bulanan, dan gaji impian 
pegawai dengan judul Dream Salaries, dengan catatan nama belakang 
pegawai ditampilkan dalam huruf kapital, sedangkan gaji bulanan dan gaji
 impian ditampilkan dalam format $99,999. Gunakan fungsi-fungsi pada 
latihan-latihan sebelumnya, dan tampilkan hasil query tersebut dengan 
format:&lt;br /&gt;
&amp;lt;last_name&amp;gt; earns &amp;lt;salary&amp;gt; monthly but wants &amp;lt;3 * salary&amp;gt;&lt;br /&gt;
Contoh : ALLEN earns $1,100 monthly but wants $3,300.&lt;br /&gt;
SELECT upper(last_name) | | ‘ earns ‘ | | TO_CHAR(salary,’fm$9,999′) | |&lt;br /&gt;
‘ but wants ‘ | | TO_CHAR(salary*3,’fm$9,999′) “Dream Salaries”&lt;br /&gt;
FROM employee;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/6487375964972025743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-fungs-pada-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6487375964972025743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6487375964972025743'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/fungsi-fungs-pada-sql.html' title='FUNGSI-FUNGS PADA SQL ORRACLE'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8249511261829305238.post-6790060028448990234</id><published>2012-06-01T12:28:00.000+07:00</published><updated>2012-06-01T12:28:45.015+07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="SHELL SCRIPT"/><title type='text'>SHELL SCRIPT READ XML</title><content type='html'>&lt;code&gt;#!/bin/bash&lt;/code&gt;
&lt;br /&gt;
&lt;code&gt;#Looking for four keywords in here&lt;br /&gt;
for key in changelog name date email&lt;br /&gt;
do&lt;br /&gt;
OUTPT=`grep  $key log.xml | tr -d &#39;\t&#39; | sed &#39;s/^\([^&amp;lt;].*\)$/\1/&#39; `&lt;br /&gt;
eval ${key}=`echo -ne \&quot;&quot;${OUTPT}&quot;\&quot;`&lt;br /&gt;
done&lt;/code&gt;&lt;br /&gt;

&lt;code&gt; &lt;/code&gt;&lt;br /&gt;

&lt;code&gt;# Getting the results in four specific arrays&lt;br /&gt;
changelogarr=( `echo ${changelog}` )&lt;br /&gt;
namearr=( `echo ${name}` )&lt;br /&gt;
datearr=( `echo ${date}` )&lt;br /&gt;
emailarr=( `echo ${email}` )&lt;/code&gt;&lt;br /&gt;

&lt;code&gt; &lt;/code&gt;&lt;br /&gt;

&lt;code&gt;#Print all Arrays&lt;br /&gt;
echo ${changelogarr[@]}&lt;br /&gt;
echo ${namearr[@]}&lt;br /&gt;
echo ${datearr[@]}&lt;br /&gt;
echo ${emailarr[@]}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;alt2&quot; style=&quot;border: 1px inset; margin: 0px; overflow: auto; padding: 6px;&quot;&gt;SECT=&quot;subsection1&quot;
&lt;acronym title=&quot;Stream Editor&quot;&gt;sed&lt;/acronym&gt; -n &quot;/&amp;lt;$SECT&amp;gt;/,/&amp;lt;\\\\$SECT&amp;gt;/ p&quot; data.xml | &lt;acronym title=&quot;Stream Editor&quot;&gt;sed&lt;/acronym&gt; &#39;1d;$d&#39; &amp;gt;temp
while read L
do
    eval &quot;$L&quot;
done &amp;lt; temp
echo &quot;X=&#39;$X&#39; - Y=&#39;$Y&#39; - Z=&#39;$Z&#39;&quot;&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://neonevz.blogspot.com/feeds/6790060028448990234/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://neonevz.blogspot.com/2012/06/shell-script-read-xml.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6790060028448990234'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8249511261829305238/posts/default/6790060028448990234'/><link rel='alternate' type='text/html' href='http://neonevz.blogspot.com/2012/06/shell-script-read-xml.html' title='SHELL SCRIPT READ XML'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/05754312506249754841</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>