forms - How do you change a text variable to an int in PHP? -
I have a variable that is inputted in a text field by a POST call.
Lenght: "text" id = "lenght" size = "2" />
From php code:
$ length = $ _POST ['band']; $ Url = substr ($ url, 0, $ length); It does not seem to work and there is only one reason that I think this is not working, because the $ length is defined as text and No interval
two things:
-
this does not work Because you misspelled length & lt; -> Length
-
The correct way to convert the string to an integer is using the function infall.
$ length = interval ($ _ POST ['length']); $ Url = substr ($ url, 0, $ length);
Comments
Post a Comment