BigCanadian Posted November 22, 2006 Share Posted November 22, 2006 hey guys, Im afraid I will be posting a lot of questions as I slowly work my way through these tutorials... simple question though.it says that it can convert this string into an integer what I dont understand is I thoguht integers could only be numbers... so how can he change the $mystring into an integer?<?php $mystring = "wombat"; $myinteger = (integer)$mystring?>heres the link[url=http://hudzilla.org/phpwiki/index.php?title=Forcing_a_type_with_type_casting]http://hudzilla.org/phpwiki/index.php?title=Forcing_a_type_with_type_casting[/url] Quote Link to comment https://forums.phpfreaks.com/topic/28060-yet-another-question-from-me/ Share on other sites More sharing options...
Philip Posted November 22, 2006 Share Posted November 22, 2006 From what I understand:It will keep it an integer (number) until there is a letter. After the letter, it will not echo anything. If there are no numbers, it will show a 0[code]<?php $mystring = "1c2234234a3"; $myinteger = (integer)$mystring; echo $myinteger;?>[/code]Will output: 1[code]<?php $mystring = "12234234a3"; $myinteger = (integer)$mystring; echo $myinteger;?>[/code]Will output: 12234234[code]<?php $mystring = "abc"; $myinteger = (integer)$mystring; echo $myinteger;?>[/code]Will output: 0 Quote Link to comment https://forums.phpfreaks.com/topic/28060-yet-another-question-from-me/#findComment-128384 Share on other sites More sharing options...
BigCanadian Posted November 22, 2006 Author Share Posted November 22, 2006 see thats what Im thinking too... but then why would he use an example which he cant really turn into an integer for this part in the book? Quote Link to comment https://forums.phpfreaks.com/topic/28060-yet-another-question-from-me/#findComment-128387 Share on other sites More sharing options...
wildteen88 Posted November 22, 2006 Share Posted November 22, 2006 He is just giving an example. However not a very clear example. Quote Link to comment https://forums.phpfreaks.com/topic/28060-yet-another-question-from-me/#findComment-128771 Share on other sites More sharing options...
BigCanadian Posted November 23, 2006 Author Share Posted November 23, 2006 alrighty, thanks Quote Link to comment https://forums.phpfreaks.com/topic/28060-yet-another-question-from-me/#findComment-128976 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.