How to use 'ASCII art' string in a program?

王林
Release: 2024-02-09 09:24:09
forward
499 people have browsed it

如何在程序中使用“ASCII art”字符串?

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!

Question content

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:

_      _        _   
          (_)    | |      | |  
  ___ _ __ _  ___| | _____| |_ 
 / __| '__| |/ __| |/ / _ \ __|
| (__| |  | | (__|   <  __/ |_ 
 \___|_|  |_|\___|_|\_\___|\__|
Copy after login

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
Copy after login

When I try to convert the above into a string literal, my code doesn't work.

Workaround

You may be looking for raw string literals:

asciiArt := `           _      _        _   
          (_)    | |      | |  
  ___ _ __ _  ___| | _____| |_ 
 / __| '__| |/ __| |/ / _ \ __|
| (__| |  | | (__|   <  __/ |_ 
 \___|_|  |_|\___|_|\_\___|\__|`

fmt.Println(asciiArt).
Copy after login

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!

source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!