i understand in wordpress loop


will output the publish id, if i wish to set $var = the publish id what must i do?

Rather than the_ID(), which echoes its result, make use of the function get_the_ID(), which returns the ID and you will assing it to some variable for use inside your php script.

$postid = get_the_ID();
/* do here what you need with $postid.. */

FYI, there is a nice official repository of Wordpress APIs, the CODEX