php变量似乎是相同的,但它们并不完全相同

I have 2 php variables:

$account_name

$my

If I use function:

var_dump($account_name);

I get:

string(192) "admin"

$account_name is displayed like a link to account name

If I use function:

var_dump($my);

I get:

string(5) "admin"

How can I change variable $account_name that return my only "admin" String.

I have problem because if I use $account_name in SQL query nothing happens but if I use $my it works.

It might be the case that your $account_name contains html tags. Since you are viewing it in browser, it is processed as html. You need to extract the value from those tags.

Take a look at this post.

Try:

$account_name = strip_tags($account_name);

strip_tags reference

It is likely that your string contains non readable characters. Try to strip the string using this example:

var_dump(preg_replace("/[^(\x20-\x7F)]*/", '', $account_name));

If it works it should return: string(5) "admin"

How are you setting your variables?

If you're getting it from a form like this:

<form action="/" method="get">
    <input name="username" placeholder="Username">
    <button>click me</button>
</form>

you should simply collect the value of the input extracting the value in php

<?php $account_name = $_GET["username"]; echo $account_name; ?>

In some cases you might want to strip the variables strip($_GET["username"]); to remove spaces before and after the string