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?

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

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

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

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


//normal code not in a function
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>] ";
echo "[<a href=\"admin.php\">Admin Center</a>] ";
echo "[<a href=\"process.php\">Logout</a>]";
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");

Jan 29 '07 #4

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.