Jump to content

What is raw ?


terryds

Recommended Posts

There is no data type like that in php. You may be refering to other thing?

Link to comment
Share on other sites

Raw data usually means it has not been processed in any way. For example. all the user data that comes in the $_POST array is in string format. It needs to be converted if you want to work with it as a float or something else, or you might need to filter it, sort it, combine it, etc.

  • Like 1
Link to comment
Share on other sites

Would you please tell me how to convert it.. When i input int(1) in the form with the post method, the result will always be string(1) "1"....Can you tell me how to convert it so the result won't be a string but int(1) ??

Link to comment
Share on other sites

Oh.. I found that (int) $var; can convert that.... But, when i type a string "aaa" in the input, the result's always be 0... How to make the result become a string "aaa" too ? And, When i type a float number, how to make the result become a float too ? Can you tell me how to do that ?

Link to comment
Share on other sites

SOLVED!!! I found this myself

<?php// Functions function raw(){if (preg_match('/^[0-9]+$/', $_POST['post'])) {$a = (int) $_POST['post'];var_dump($a);} else if (preg_match('/^[0-9]+\.[0-9]+$/', $_POST['post'])) {$a = (float) $_POST['post'];var_dump($a);} else {$a = (string) $_POST['post'];var_dump($a);}} ?><!DOCTYPE html><html><head><meta charset="utf-8"><title>$_POST check type</title></head><body><form action="" method="post"><label for="post">Check the type</label><input type="text" id="post" name="post"></form><?php if (isset($_POST['post'])): ?><p>The type is <?php raw(); ?></p><?php endif; ?></body></html>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...