Ad

I Want To Capitalize The Value Of The Php String In This Echo Block

- 1 answer

Here is my block of php I want to capitalize the first letter in the value the string returns from $user->data['username_clean']

The method I tried didn't work with this error.

Fatal error: Call to undefined method

It is likely however that I formatted it incorrectly. php code is here.

<?php 
if ($user->data['user_id'] == ANONYMOUS) {
   echo '
        <li class="dropdown">
           <a target="_blank" rel="nofollow noreferrer" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Login<span class="caret"></span></a>
           <ul class="dropdown-menu">
              <form id="loginform" method="post" action="/forums/ucp.php?mode=login">
                 <label>Username</label>
                 <input name="username" type="text" id="username" class="width120 textbox
opdown-menu">
              <form id="loginform" method="post" action="/forums/ucp.php?mode=login">
                 <label>Username</label>
                 <input name="username" type="text" id="username" class="width120 textbox" tabindex="1" />
                 <label>Password</label>
                 <input name="password" type="password" id="password" class="width120 textbox" tabindex="2" />
                  <label>Remember Me?:</label>
                  <input type="checkbox" name="autologin">
                  <input type="submit" value="Login" name="login">
                  <input type="hidden" name="redirect" value="indextest.php"
              </form>
        </li>';
} else { 
    echo '
        <li class=dropdown>
        <a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"  aria-haspopup="true" aria-expanded="false">',  $user->data['username_clean'], '<span class="caret"></span></a>
        <ul class="dropdown-menu">
                    <li><a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="#">User Control Panel</a></li>
                    <li><a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="#">Profile</a></li>
                    <li><a target="_blank" rel="nofollow noreferrer" target="_blank" rel="nofollow noreferrer" href="#">Logout</a></li>
                  </ul>
        </li>';
}
?>
Ad

Answer

To uppercase the first character of a string use

ucfirst( $user->data['username_clean'] );
Ad
source: stackoverflow.com
Ad