开发者

Making Values Lower-case and stripping slashes

开发者 https://www.devze.com 2023-02-07 08:04 出处:网络
I am pulling values submitted from a form and displaying them in a couple different formats.Sometimes I need the values to be echo-ed in lowercase and sometimes I need any capitalization preserved, de

I am pulling values submitted from a form and displaying them in a couple different formats. Sometimes I need the values to be echo-ed in lowercase and sometimes I need any capitalization preserved, depending on the section of the page. However, I开发者_JS百科 need all values to have the slashes stripped out.

I am using the following format to echo the lowercase values

<?php echo strtolower ( $keyword ); ?>

This is working fine. Though, adding 'stripslashes' to that is throwing an error. I'm sure I'm not formatting it correctly.

How do I accomplish both of these items?

Update

I was simply asking a question related to PHP formatting and syntax but, in order to appease Oli Charlesworth . . .

<?php echo stripslashes strtolower ( $keyword ); ?>

This is the code I had tried. And this is the error it was throwing ...

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/u/s/e/username/html/folder/code.php on line 63


echo strtolower(stripslashes($keyword));

Should do it.

Also note, you could do...

<span style="text-transform: lowercase"><?php echo stripslashes($keyword); ?></span>

Update

Your code...

<?php echo stripslashes strtolower ( $keyword ); ?>

...is not correct code, because each function needs to take its arguments within parenthesis. You need to wrap them in their respective parenthesis - so the return value from the inner becomes the argument for the outer.


You really need to provide the code you are using to stripslashes before we can assist properly.

But the following code should stripslashes:

<?php echo strtolower(stripslashes($keyword)); ?>

I cant think of any reason why that wouldn't work unless you are using an ancient version of PHP. You could also use (although this will remove all slashes including //):

<? echo strtolower(str_replace("\\", "", $keyword)); ?>

You will need to utilise some kind of conditional to decide when to keep capitals or not.

0

精彩评论

暂无评论...
验证码 换一张
取 消