0

Anybody can explain about my question i have search over the web but never find right answer ?

7
Contributors
6
Replies
48
Views
3 Years
Discussion Span
Last Post by timetraveller1992
0

I assume you mean code reusability.

If so, you need to learn to develop class and use them as and when required in muliple pages

0

Please expand the question,
as it is it could be anything

how to create a database driven site,
how to copy n paste code in my editor

a wide diverse range of possibility
the more info you give, the better and more specific the answers can be

utrivedi's above answer is correct, and I think pretty likely,
but there have been many occassions where the OP has been dropped in the deep end trying to maintain someone else's code, and , just thought I'd ask

Edited by almostbob

0

if it's a identical page with different info, wouldnt a ?id page work? ofc this would lead to knowledge if there is a database involved

0

There are several ways to get this done. Depends on what you need it for.

These are some scenarios I use...

Form Submission

if($_SERVER['REQUEST_METHOD'] !== 'POST')
{ .... Code to show form .... }
else
{ .... Code to perform form submission .... }

User Login

if($_COOKIE['loggedin'] !== true) // You can use session too which is better for this scenario
{ .... Code to show login page .... }
else
{ .... Code to show home page .... }

Several Pages in One Script

if(isset($_GET['page']))
 {
    switch($_GET['page']) 
        {
        case 'home':
            ... Code to show home page ...
            break;
        case 'register':
            ... Code to show register page ...
            break;
        default:
            ... Code to show 404 not found page ...
        }
 }

Based on your need you can show different pages. I extend this further in my apps to show different layouts for different mobiles by detecting their OS and browser from the $_SERVER['USER_AGENT']. This too can be used as a parameter for showing different values using same file. I hope this is what you were looking for.! And your welcome

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.