Posts

Showing posts from May, 2020

Notice: Undefined index: name in test.php on line 3 Error On PHP 7

Image
Photo by  KOBU Agency  on  Unsplash Writing a PHP application is so simple and fun because the PHP is interpreted, you don’t need to compile first your program to run it. As soon as you save the project file you are working on, you can just execute from the browser. Consider this PHP file named test.php below <?php $array = array(); echo $array['name']; For really beginners PHP Programmers, some little error warning can be frustrating because most of them don't know how to handle and overcome the error. The error Notice: Undefined index: name in test.php on line 3 from the code above is telling you two possible situations: the variable doesn’t have the name key, the variable is empty, so it doesn’t the name key Solution Before accessing a variable key that may not exist, or the array itself is a Null or empty, you can first check the availability of the key using the EMPTY function. From the code example above that shows error notification, you can fix the problem so t

Blogging is hard, writing content for public readers is really hard, consistency is the key

Image
Photo by  Caroline Attwood  on  Unsplash When I was in High school and learning for the first time about creating a website or blog, I really enjoyed designing and writing on that blog which I lost.  It's a fun activity when you are doing the thing that you really like, for me working with a computer is the thing that I am very good at and enjoy spending time with.I am kind of introverted and have very few friends, so the outside world is not attracting me. Now I have grown up and blogging is not just a hobby anymore. Somehow I need to make a living because the job I currently work in is really not enjoyable. Then Blogging becomes less fun and somewhat intimidating.  Writing content for public readers is really hard, you are forced to have one level of knowledge above your readers, if they find you somewhat incapable of your writing, they’ll just leave and without recurring visitors, your number of visitors will be very limited. It’s a lot harder writing as an independent blogger

Tree Traversal in Java using Visitor pattern and For loop Example Codes

Image
Java Oracle Writing codes in Java is supposed to be reusable, it means that your code can be reused by yourself and other people working on similar things you do without rewriting the same code block  over and over. This is an example of object oriented passion on how you can use an object that could possibly have infinite children. You can use this class so you don’t need to write a loop over and over. Firstable given data person with children and grandchildren below. Now we can use for loop and visitor pattern to visit all the children recursively. 1. For loop The first example is a usual, easy to understand Example of how you write a Recursive method to visit tree traversal children using for loop. Using for loop is really really simple but Somewhat looks not an elegant way, and it could lead into bugs if you misplace variables before and after calling the recursive method. When the code gets bigger it becomes a mess. 2. Visitor Pattern And here’s the Object oriented way, using a

Java Map And Filter, A lambda or anonymous expression example

Image
Java lambda expression  It’s been a while since JDK 8 release, since that version of Java the language, it adopted many new nicer syntax, the one that i love is the Lambda expressions.  Lambda or anonymous function can make you write in a nice looking functional one liner code, for example below is a Java way of looking for keywords if they match in an Array, true if match and false otherwise. //given array List<String> words = Arrays.asList( "foo", "bar", "cool" ); //check if 'cool' exists boolean isCool = words.stream().anyMatch(word -> word.equals("cool")); 1. Map Map objects to another value as specified by a Function object, example below to Reduce List of object Person, to just List of person names. 2. Filter Filter objects that match a Predicate object. Example below is an example to filter people with certain age. import lombok.Data; import java.util.Arrays; import java.util.List; import java.util.logging.Logger; import j

Popular posts from this blog

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

How To Connect SSH Using PEM Certificate On Windows

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Flutter Button With Left Align Text and Icon