terryds Posted June 22, 2013 Share Posted June 22, 2013 Can you tell me what raw is ? I heard it's a type like integer, float, etc... Link to comment Share on other sites More sharing options...
birbal Posted June 22, 2013 Share Posted June 22, 2013 There is no data type like that in php. You may be refering to other thing? Link to comment Share on other sites More sharing options...
jeffman Posted June 22, 2013 Share Posted June 22, 2013 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. 1 Link to comment Share on other sites More sharing options...
terryds Posted June 23, 2013 Author Share Posted June 23, 2013 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 More sharing options...
terryds Posted June 23, 2013 Author Share Posted June 23, 2013 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 More sharing options...
terryds Posted June 23, 2013 Author Share Posted June 23, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now