PHP Functions menu

Shout-Out

User Tag List

Results 1 to 1 of 1
  1. #1
    tttommeke's Avatar Banned
    Reputation
    1
    Join Date
    Jul 2007
    Posts
    613
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Functions

    Functions are pieces of script that can be used more then 1 time or in multiple scripts. Let's say you want to check if someone has a valid session ID but don't want to place on every top of your page a code that checks it. Then you can use a function that will replace a 10 line code into a 1 line code that calls for the function !

    The normal view of a function is :
    Function function-name($Parameter1,$Parameter2,...) {
    Some code
    }

    Example :

    functions.inc.php
    PHP pastebin - collaborative debugging tool

    So this function will check if a session is valid. If the session is valid he will print out logged in, else he will print out Not logged in.

    index.php
    PHP pastebin - collaborative debugging tool

    The output will look like :
    Not logged in
    logged in!


    Why did he change the second line ? Because, as you can see, I have defined the $_SESSION['logged'] to the requested needs to get a true response.
    The use of functions can decrease the total size of your pages so a faster load is possible ! Also functions are called Snippets because they aren't a full code. So when you are searching for functions, search for snippets.

    PHP Functions

Similar Threads

  1. .php problems
    By Etaile in forum Community Chat
    Replies: 6
    Last Post: 07-31-2010, 07:03 PM
  2. Replies: 3
    Last Post: 04-30-2009, 01:36 PM
  3. Function locating.
    By HolyForce in forum World of Warcraft General
    Replies: 0
    Last Post: 03-03-2007, 07:19 AM
  4. Hey PHP People!
    By Tory in forum Community Chat
    Replies: 0
    Last Post: 09-30-2006, 07:40 PM
All times are GMT -5. The time now is 08:35 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search