I don't use command line PHP, so I replicated your code to try it out for the browser.
$number = NULL;
$handle = fopen("newfile.txt", "r");
printf("I'd like an integer please: <br />");
fscanf($handle, "%d\n", $number);
Returns true once the 122 is found. No clue at all how this is working differently for you on the command line.
Your code is returning 0 (false) when you enter 4.45 because that's not an integer, it's a floating point number. Integers are only whole numbers.
To input floating point numbers, you need to use [FONT="Courier New"]%f[/FONT] instead of [FONT="Courier New"]%d[/FONT]. However, you can't input them both in your code because you're specifically asking for integers and are checking for them with is_int().
You could input your data as a string with [FONT="Courier New"]%s[/FONT], but you'd need to use the address-of operator with that, and if you haven't learnt much about PHP, memory addresses, memory allocation, arrays or pointers (references), I wouldn't worry.
Anyway, I think this should work for you:
$number = NULL;
printf("I'd like an integer please: ");
fscanf(STDIN, "%d\n", $number);
Try to use the while-loop format for things like this, as it guarantees the code doesn't get stuck in an infinite loop and will always pause the loop between data input. You're code is using a recursive function call (calling a function within itself) and has 2 calls to the same function. Not advisable for this and unnecessary.
I hope the code I gave you works, but as I said I don't use the command line so it may very well be different.