Go Back   Access World Forums > Apps and Windows > Web Design and Development > PHP & MySQL

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-26-2016, 08:36 AM   #1
Steve R.
Retired
 
Steve R.'s Avatar
 
Join Date: Jul 2006
Location: Morehead City, North Carolina
Posts: 1,734
Thanks: 95
Thanked 104 Times in 92 Posts
Steve R. will become famous soon enough Steve R. will become famous soon enough
Recommend Location to Set Some PHP Parameters

I am modifying the code to some of my (home LAN) web-pages in the hopes of streamlining and reducing unnecessary code. I am wonder what the industry standard practice is for locating code that will be used by subsequent web-pages. (Note: this project operates solely on a home LAN)

Below are the first few lines of the "homepage" (index.php). I just moved the line "require_once 'php_functions/functions.php';" into this block of code. So far, no errors have been experienced. So it is looking "good". Would it be appropriate to continue moving PHP code into this block?

Code:
<?php
// Start the session
session_start();
// Get current Working Directory			
$_SESSION['cwd'] = getcwd();
// This may work for all subsequent pages.  Need to verify.  
require_once 'php_functions/functions.php';	
?>

__________________
Now using Linux (Ubuntu).
Doing database development with Firefox/MariaDB.
Steve R. is offline   Reply With Quote
Old 08-30-2016, 09:02 AM   #2
dan-cat
Newly Registered User
 
dan-cat's Avatar
 
Join Date: Jun 2002
Location: KY,USA
Posts: 3,433
Thanks: 0
Thanked 18 Times in 18 Posts
dan-cat will become famous soon enough
Re: Recommend Location to Set Some PHP Parameters

I do a fair bit of wordpress plugin development so I can show you how it's done in that CMS. Basically you create a class and include functions within that class to return what you need. You then instantiate that class by including the appropriate php file.

For example

Code:
class MyFirstClass {

    /**
    * Constructor.
    */
    function MyFirstClass() {

//Put whatever you code you need here when the class is created
}


function outputSomeHtml(){
     echo 'some html';
}

}

$myClass = new MyFirstClass();

Now in your web page include the file where the class resides...

Code:
require_once 'php_functions/myfirstclass.php';
and you can now use that class for what you will...

Code:
$myClass->outputSomeHtml();
__________________
Pinky has always been there for me
dan-cat is offline   Reply With Quote
Old 08-30-2016, 10:22 AM   #3
Steve R.
Retired
 
Steve R.'s Avatar
 
Join Date: Jul 2006
Location: Morehead City, North Carolina
Posts: 1,734
Thanks: 95
Thanked 104 Times in 92 Posts
Steve R. will become famous soon enough Steve R. will become famous soon enough
Re: Recommend Location to Set Some PHP Parameters

Good one. I'm not yet up-to-speed on classes. I understand the concept and how it works. You have given me a new approach. However, I'm still near the bottom of the learning curve and trying to claw my way up. You have answered the question, now it is up to me to successfully apply. Thanks.

__________________
Now using Linux (Ubuntu).
Doing database development with Firefox/MariaDB.
Steve R. is offline   Reply With Quote
Reply

Tags
mysql , php

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Location click location on Image Bruce19 Modules & VBA 1 08-07-2012 12:27 AM
Stock Transaction Table - Location A to Location B Lyconal Forms 8 06-01-2009 06:15 AM
Can any one recommend a VBA course? chunk777 Excel 1 07-03-2007 05:31 AM
Recommend Reading? ChickeyD Modules & VBA 3 04-30-2004 10:46 AM
Recommend a book Kraj Modules & VBA 1 08-30-2001 07:04 AM




All times are GMT -8. The time now is 10:13 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World