Show username only if logged in in a else no directly name

Hi I’m looking all over but I don’t find the solution: I have an infobox with: Hi, welcome to our “some text”

Now I’d like to add posibility for logged in users “Hello Tony, welcome to our “some text”

I tried following code snippet:

<div id="infoBox"> <button class="cross" type="button">X</button>   <p> Hello </p> <?php global $  current_user; wp_get_current_user(); ?> <?php if ( is_user_logged_in() ) {   echo 'Username: ' . $  current_user->user_login . "\n"; echo 'User display name: ' . $  current_user->display_name . "\n"; }  else { wp_loginout(); } ?>      <p>  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gub    </p> </div> 

but there’s a fatal error in my XAMPP testing environment:

Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() in /opt/lampp/htdocs/wordpress/wp-content/plugins/stoerer/stoerer.php:31 Stack trace: #0 /opt/lampp/htdocs/wordpress/wp-settings.php(377): include_once() #1 /opt/lampp/htdocs/wp-config.php(90): require_once(‘/opt/lampp/htdo…’) #2 /opt/lampp/htdocs/wordpress/wp-load.php(42): require_once(‘/opt/lampp/htdo…’) #3 /opt/lampp/htdocs/wordpress/wp-blog-header.php(13): require_once(‘/opt/lampp/htdo…’) #4 /opt/lampp/htdocs/wordpress/index.php(17): require(‘/opt/lampp/htdo…’) #5 {main} thrown in /opt/lampp/htdocs/wordpress/wp-content/plugins/stoerer/stoerer.php on line 31 There has been a critical error on your website.