By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,643 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,643 IT Pros & Developers. It's quick & easy.

PHP functions

P: 63
Is it possible to mix PHP functions with normal PHP code. Does it work?

Thanks
Jan 26 '07 #1
Share this Question
Share on Google+
4 Replies


Motoma
Expert 2.5K+
P: 3,235
Is it possible to mix PHP functions with normal PHP code. Does it work?

Thanks
I'm not entirely sure what you are asking. Could you give a little more detail about what you are trying to do?
Jan 26 '07 #2

cassbiz
100+
P: 202
Functions are put into the <?php ?> . Are you referring to php classes? If you are they are simply put a collection of functions already written which assist you to complete whatever task it is that you are working on.
Jan 27 '07 #3

P: 63
I mean something like

[PHP]

//normal code not in a function
if($session->logged_in)
{
echo "<h1 align =\"center\">Logged In</h1>";
echo "Welcome <b>$session->username</b>, you are logged in. <br><br>"
."[<a href=\"userinfo.php?user=$session->username\">My Account</a>] "
."[<a href=\"useredit.php\">Edit Account</a>] ";
if($session->isAdmin())
{
echo "[<a href=\"admin.php\">Admin Center</a>] ";
}
echo "[<a href=\"process.php\">Logout</a>]";
{
//funtion
function login($subuser, $subpass, $subremember){
global $database, $form; //The database and form object

/* Username error checking */
$field = "user"; //Use field name for username
if(!$subuser || strlen($subuser = trim($subuser)) == 0){
$form->setError($field, "* Username not entered");
}


[/PHP]
Jan 29 '07 #4

Motoma
Expert 2.5K+
P: 3,235
Yes, it is perfectly fine to mix the two that way.
Jan 29 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.