Time for action – Welcoming the user on Neko & PHP
We are going to write a simple program that asks the user their name and prints a little welcome message along with the date. This program should work with the same codebase on Neko and PHP.
The following are the steps you should follow to write this program:
Identify what classes you will need to print text and read from the keyboard.
Identify what classes are in a platform-specific package.
Add imports for those classes.
Run and test.
You should get the following output:
The following is the final code you should have produced:
#if neko import neko.Lib; import neko.io.File; #elseif php import php.Lib; import php.io.File; #end class Main { static function main() { //Print a prompt Lib.print("Please enter your name: "); //Read the answer var name = File.stdin().readLine(); //Print the welcome message Lib.println("Welcome " + name); //Store the date var date = Date.now(); //Concatenate...