Home >Backend Development >Golang >How to use 'ASCII art' string in a program?
In programming, using ASCII art strings can add some unique visual effects to the program. ASCII art is an image composed of characters, which can be displayed as text in the console. In PHP, we can use specific functions and techniques to create and display ASCII art. In this article, PHP editor Yuzai will introduce to you how to use ASCII art strings in programs to make your programs more interesting and personalized. Let’s explore together!
I was wondering if adding ASCII Art would make my project better, in addition to fixing all print statements. I tried adding ASCII Art to my project using backticks but that doesn't work.
I tried adding the ASCII given below as the first thing shown to the user but I couldn't get it to work:
_ _ _ (_) | | | | ___ _ __ _ ___| | _____| |_ / __| '__| |/ __| |/ / _ \ __| | (__| | | | (__| < __/ |_ \___|_| |_|\___|_|\_\___|\__|
Update: After implementing string literals, the above issue has been resolved. However, I still cannot make ASCII Art, such as the following:
88 88 "" 88 ,d 88 88 ,adPPYba, 8b,dPPYba, 88 ,adPPYba, 88 ,d8 ,adPPYba, MM88MMM a8" "" 88P' "Y8 88 a8" "" 88 ,a8" a8P_____88 88 8b 88 88 8b 8888[ 8PP""""""" 88 "8a, ,aa 88 88 "8a, ,aa 88`"Yba, "8b, ,aa 88, `"Ybbd8"' 88 88 `"Ybbd8"' 88 `Y8a `"Ybbd8"' "Y888
When I try to convert the above into a string literal, my code doesn't work.
You may be looking for raw string literals:
asciiArt := ` _ _ _ (_) | | | | ___ _ __ _ ___| | _____| |_ / __| '__| |/ __| |/ / _ \ __| | (__| | | | (__| < __/ |_ \___|_| |_|\___|_|\_\___|\__|` fmt.Println(asciiArt).
You can apply these raw string literals at various places in your code to avoid repeated calls to fmt.Println()
.
The above is the detailed content of How to use 'ASCII art' string in a program?. For more information, please follow other related articles on the PHP Chinese website!