How to: fmt.Println in PHP
Outputting to your shell or terminal to inform the user of the outcome of a program or valuable debugging information is an essential of every programming language.
GOlang
In Golang you can output text and variables to the terminal via various methods, but fmt
is a commonly used one.
package main
import "fmt"
func main() {
fmt.Println("Hello World!")
// Hello Jonathan!
name := "Jonathan"
fmt.Printf("Hello %s!\n", name)
fmt.Printf("1 + 1 is %d!\n", 1+1)
// %v for unknown variable types
fmt.Printf("unknown variable type: %v without newline", 40.1)
}
More fmt.Println References
PHP
In PHP you can print to the terminal or the log by using var_dump
:
<?php
$a = array(1, 2, array("a", "b", "c"));
var_dump($a);
?>