Jump to content
php.lv forumi

funkcijas izveidošana


anonīms

Recommended Posts

Gribu pamēģināt izveidot f-ju, kas ļautu man atvieglot dzīvi.

Tātad ir gabals, kas pārbauda vai admins ir ielogojies

if(isset($_SESSION['logged']) and $_SESSION['logged']+1800 > time()) { admins redz šo! }

lai katru reizi nebūtu jāraksta garo kodu, tad vēlos to visu apvienot f-jā, kas izskatītos apmēram tā

admins() { admins redz }

Tā maz ir iespējams izveidot? un ja jā, tad varbūt mazu piemēru...

Edited by anonīms
Link to comment
Share on other sites

tiku galā

 

	function admins()
{
if(isset($_SESSION['logged']) and $_SESSION['logged']+1800 > time()) {
return true;
}
else
{
return false;
}
}

$admins = admins();

 

un tad

if($admins) { tu esi admins } else { neko neraadam }

 

sorry par dp

Edited by anonīms
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...