Click here to Skip to main content
15,891,787 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Were do the variables reside when using PHP? Pin
led mike17-Apr-08 8:48
led mike17-Apr-08 8:48 
GeneralRe: Were do the variables reside when using PHP? Pin
Joan M17-Apr-08 9:33
professionalJoan M17-Apr-08 9:33 
GeneralRe: Were do the variables reside when using PHP? Pin
Bradml18-Apr-08 21:34
Bradml18-Apr-08 21:34 
GeneralRe: Were do the variables reside when using PHP? Pin
Johnny ²17-Apr-08 8:51
Johnny ²17-Apr-08 8:51 
GeneralRe: Were do the variables reside when using PHP? Pin
Joan M17-Apr-08 9:36
professionalJoan M17-Apr-08 9:36 
AnswerRe: Were do the variables reside when using PHP? Pin
User 988517-Apr-08 21:12
User 988517-Apr-08 21:12 
GeneralRe: Were do the variables reside when using PHP? Pin
Joan M17-Apr-08 21:18
professionalJoan M17-Apr-08 21:18 
GeneralRe: Were do the variables reside when using PHP? Pin
User 988517-Apr-08 21:40
User 988517-Apr-08 21:40 
No problem. Just in case you are writing a PHP based website from scratch, try to do the following:

Organize code such that functions that provide core functions (such as accessing databases) be kept in separate php files. Then, you can use

<?php
require 'core.php'
?>

to include it in any other PHP file.

This way, you can reuse the functions, there will be as little PHP code in the HTML pages. It is much more manageable that way.

I go to another level usually, where PHP scripts corresponding to user actions are kept in another PHP file. Conceptually similar to MVC.

view.php has all the HTML with minimal PHP calls to functions in controller.php. Controller.php is specific to the view.php and contains all the PHP code specific to that page. All reusable functions between multiple pages go into core.php. I use multiple core files to aggregate functions based on functionality. For example: authentication goes into one file.

In the view.php, I just use

--
require 'core.php';
require 'controller.php';

HTML with function calls to controller.php.

--

I hope this helps. All this is just a matter of individual preference. I have found it much better to manage in the long term.

modified 29-Aug-18 21:01pm.

GeneralRe: Were do the variables reside when using PHP? Pin
Bradml18-Apr-08 21:40
Bradml18-Apr-08 21:40 
GeneralRe: Were do the variables reside when using PHP? Pin
User 988518-Apr-08 22:05
User 988518-Apr-08 22:05 
GeneralRe: Were do the variables reside when using PHP? Pin
Bradml18-Apr-08 22:34
Bradml18-Apr-08 22:34 
GeneralRe: Were do the variables reside when using PHP? Pin
User 988518-Apr-08 22:49
User 988518-Apr-08 22:49 
GeneralRe: Were do the variables reside when using PHP? Pin
Bradml18-Apr-08 22:54
Bradml18-Apr-08 22:54 
GeneralRegister an event such Pin
Christiaan Laubscher16-Apr-08 23:12
Christiaan Laubscher16-Apr-08 23:12 
GeneralRe: Register an event such Pin
Paddy Boyd16-Apr-08 23:40
Paddy Boyd16-Apr-08 23:40 
GeneralView revit file in html page Pin
Ramya.G16-Apr-08 21:57
Ramya.G16-Apr-08 21:57 
GeneralRe: View revit file in html page Pin
Vasudevan Deepak Kumar17-Apr-08 22:12
Vasudevan Deepak Kumar17-Apr-08 22:12 
GeneralClosing Browser Pin
Brendan Vogt16-Apr-08 21:47
Brendan Vogt16-Apr-08 21:47 
GeneralRe: Closing Browser Pin
Ashish Sehajpal17-Apr-08 6:11
Ashish Sehajpal17-Apr-08 6:11 
GeneralRe: Closing Browser Pin
Vasudevan Deepak Kumar17-Apr-08 22:15
Vasudevan Deepak Kumar17-Apr-08 22:15 
GeneralRe: Closing Browser Pin
Vasudevan Deepak Kumar17-Apr-08 22:13
Vasudevan Deepak Kumar17-Apr-08 22:13 
GeneralRe: Closing Browser Pin
Ashish Sehajpal18-Apr-08 4:14
Ashish Sehajpal18-Apr-08 4:14 
GeneralRe: Closing Browser Pin
Bradml18-Apr-08 21:50
Bradml18-Apr-08 21:50 
General"Retrieving currency conversion value from existing website" Pin
harsh_296116-Apr-08 20:57
harsh_296116-Apr-08 20:57 
GeneralRe: "Retrieving currency conversion value from existing website" Pin
R. Giskard Reventlov16-Apr-08 22:19
R. Giskard Reventlov16-Apr-08 22:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.