PHP Question

Her kan du få hjælp og stille spørgsmål til PHP!
Besvar
Crow
Rutineret
Rutineret
Indlæg: 64
Tilmeldt: 15. apr 2014, 11:24

PHP Question

Indlæg af Crow » 18. maj 2014, 17:44

Greeting's

i was wondering how php execute's and what would give the best result, currently i am using 1 .php as a directory that collects all functions and so on but i was wondering if php read's similar to a switch or if.

this is an example of how i have it now:

Kode: Vælg alt

$Menubar_Text = "this is just simple text within the side-menubar";
$Test = "this is just a simple test";
$Info_Text = "This website is written in jscript, css & html5 from scratch without the usage of CMS systems.";
$Planned_Text = "I am interrested in too much to study it all in my free time so i write it down so i can study it later.";
$Current_Text = "This website is part of my current hobby interrest.";
$Info_Content_Text = "this is where the content text will be written";
$Home_Content_Text = "this is content text for Home";
$Info_Content_Text = "info content text";
$Footer_Text = "This is just a simple test of the footer text through php";
in short i want to know if when you include/require a .php file where you need the lets say $Test and $Footer_Text will it then also use resources to look at the other statement's in the .php or will it similar to "switch" only use those ? i would like to know this since otherwise i would just need to make a .php with a switch that determines what .php it needs to use and split it all up in multiple document's. i want to know what would give the best result in the end and not just a short term solution that would need to be changed completely later on :)

Brugeravatar
scootergrisen
Moderator
Moderator
Indlæg: 709
Tilmeldt: 21. jun 2012, 23:40
Kontakt:

Re: PHP Question

Indlæg af scootergrisen » 18. maj 2014, 20:10

When you use include/require its the same as if you took the content of that file and put it there instead of the include/require.

One example could be that you have 2 files ved stings.
1 file for danish and 2 file for english.
And depending on what the user chooses one of the files is included.

Crow
Rutineret
Rutineret
Indlæg: 64
Tilmeldt: 15. apr 2014, 11:24

Re: PHP Question

Indlæg af Crow » 18. maj 2014, 20:27

so just that i understand it correctly, it read's it all so to get the best result i should try only to include what i need instead of a large directory but i could instead use a switch/if function to depending on the user's choice or page use another .php directory ? :)

ps. is it possible to read the url in the browser such as making a case/if where it look's at the url the user is currently on and then decides on what .php to use ?

Brugeravatar
scootergrisen
Moderator
Moderator
Indlæg: 709
Tilmeldt: 21. jun 2012, 23:40
Kontakt:

Re: PHP Question

Indlæg af scootergrisen » 18. maj 2014, 21:02

Sure its faster to only include code/variables that you use later in the code but PHP happens pretty fast.

You can use $_SERVER['SCRIPT_NAME'] but it would proberly be better to do it another way so you are not relying on the filename if you change it at a later time.

Crow
Rutineret
Rutineret
Indlæg: 64
Tilmeldt: 15. apr 2014, 11:24

Re: PHP Question

Indlæg af Crow » 18. maj 2014, 21:05

thank's :)

i will try and think of other way's :)

Besvar