this is my code
$line = trim(fgets(STDIN));
echo $line;
what browser shows:
Warning: fgets() expects parameter 1 to be resource, string given in /storage/emulated/0/coding/mobilephp

As mentioned in the article posted by @ryantroop, fgets(stream) will also return the newline. If you don't want it, you will either have to trim it or use stream_get_line(). FWIW, you can't use STDIN if your script is being read from stdin... :-) Read this:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.