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

Recommended Answers

All 6 Replies

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

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

maybe you can use a loop to create the pages.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.