Monthly Archives: June 2011

Handle Old Open PHP Tag

Continuing my previous post PHP Auto Replace Multiple Files Content, you can esily make the old php open tag <? to be handled by new php.

You have to change your php.ini file. In php.ini file, found a row with “short_open_tag = Off” then change it with “short_open_tag = On“. After that restart your apache server.

http://septiadi.com/2011/06/24/handle-old-open-php-tag/


PHP Auto Replace Multiple Files Content

Previously my best friend told me about his problems in php. He has a bunch of php file that already outdated.These files use php 4 format. He requested me if there is a way to change the format <? used in those files into <?php that used in current php format. Therefore, I made a php script to do such thing.

This script has feature:

  • List all files in current folder except the script it self
  • Read each file one by one
  • Replace requested string
  • Save it
This is the script:
<?php
//if file is too many, there is a possibility that the script exceed the max exection time
$this_file = 'index.php';//this is the script file for exception
if ($handle = opendir('.')) {
    while (false !== ($file = readdir($handle))) {
        if ($file != "." && $file != "..") {
            echo "$file\n";

			if($file != $this_file){

				$handle2 = fopen("$file", "rb");
				$contents = '';
				while (!feof($handle2)) {
				  $contents .= fread($handle2, 8192);
				}
				$contents = str_replace("<?", "<?php", $contents);// for replacing <? into <?php
				//for replacing deprecated function, you need regex
				echo htmlspecialchars($contents).'<hr><br>';
				fclose($handle2);

				$fp = fopen("$file", 'w');
				fwrite($fp, $contents);
				fclose($fp);
			}
        }
    }
    closedir($handle);
}
?>

Just copy the script into a folder where resides the files that you want to replace the content.

 http://septiadi.com/2011/06/22/php-auto-replace-multiple-files-content/

Index Post in Google

This post just merely a way to satisfy my curiousity. I wonder how many it takes for google to index my post.

The way to do it is very simple. Just make a simple post, then use the search engine to serach the permalink. In this case, I search “https://mhseptiadi.wordpress.com/2011/06/14/index-post-in-google/” in “https://www.google.com/“, just after i publish this post. I refresh the google serach engine if my post is not being indexed. When finnaly it has been indexed, the result is it has been indexed less than 30 second. I like it. 😀

Lets try it with your post.

Related Post:

http://septiadi.com/2011/06/14/index-post-in-google/


Recursive Function

Recursion (computer science), a procedure or subroutine, implemented in a programming language, whose implementation references itself” Wikipedia. In this case, Recursive Function is a function that call or reference it self to do some repetitive actions. Different with iteration function that use loop, recursion function dont use loop to do repetitive function. Therefore, Recursive Function may be called several times while the iteration function only called once.

This is simle example of recursive factorial function (example using javascript).

function Factorial_Recursive(n){
	if (n <= 1) return 1;
	else
	return n * Factorial_Recursive(n - 1);//this call itself
}

In this case, Factorial_Recursive(n) function will call itself and be executed several times if you declare the ‘n’ variable at least 2.

Other more simple example function using php.

function Simple_Recursive($n){
	if($n!=0){
		echo $n.' ';
		$n--;
		Simple_Recursive($n);
	}
}

Simple_Recursive(10);

The above function will give output “10 9 8 7 6 5 4 3 2 1”.

To put it simple, recursive funcition is a function that call it sefl to do repetitive action.

http://septiadi.com/2011/06/13/recursive-function/


Develop Creative Thinking

Today, creative becomes more popular. However, there are pros and cons about whether it is important to be creative in daily live. In my oppinion, Creative is very important. Problem solving needs kreative thinking, in this case many problems occur in our daily live.

In this article, I ll try to share about how to develop creative thinking. There are 4 guide that will help you alot in developing creative thinking.

Capturing

Idea may come out in your mind without notification, and it could easily forgotten. Therefore, start collecting your idea by preparing little note that easily carried anywhere. When your idea comes, write down it in your note. Dont be lazzy to write it down, because you may forget it. Just keep in mind, simple idea may lead you to another idea.

Surrounding

Briliant idea do not just come out by it self. You have to stimulate your brain to produce briliant idea. How? Always changing environment will help you alot in producing new idea. Changing your environment is not only changing your address. You can changing environment by simple thing such as, changing your paint wall, change route when go to office, make new friend with person that have different background from you, etc.

Challenging

Creativity sometimes comes up when you face problems in your daily live. Problems that comes in home, school, office may help you creativity grow without you notice. In my opinion Playing game will also help your brain works creatively, because many problems will you face in game. However, become addicted to game will also become problems.

Broadening

Broadening means that the diversity of your knowledge. Study new thing in your live that not related to your background/job, will also help you become more creative. In this case, your creative idea will become more broaden.

By developing those four guidelines, you will improve the capacity of your creative mind. Having creative mind may help you solve many problems in your daily live.

Good luck. Hope “Develop Creative Thinking” will help you alot.

Source:http://theperfectbizfinder.com, and other that i forgot.

http://septiadi.com/2011/06/09/develop-creative-thinking/