I'm a beginner in Joomla and a little confused with this method.
for example consider this :
where is the source of
JInput->get() get's inputs from where ?
foo are the PHP superglobals such as $_POST or $_GET. So it's data what the user submits via a form, URL or cookie to your component.
So you are receiving in a safe way a parameter that was sent to you via a HTTP method.
$myVar = $app->input->get('foo',0,'int');
is largely equivalent to:
$myVar = (int) $_REQUEST['foo'];
You should always use JInput, no matter what. You just forget about the PHP superglobals. Read the whole documentation in silence, you should know it by heart.