Jump to content

"Get" Function


Unholy Prayer

Recommended Posts

There's many ways you can do this...
- Your index.php could be a base page that includes a "memberslist" or a "login" file (You should be careful if you do something like include $_GET['act'] . '.php'; though.
- You could do file_get_contents() and get the contents to echo to the user instead of the above method.
- You could do it as a method of "get the 'act' from a database/template directory to display"
- You could use it as a method to choose which logic path you go down to display the page

It all boils down to using $_GET['act'] to determine the content of your page, and is in no way shape or form limited to the few things I listed above (which were a lot alike.)

There's many ways you can use the "index.php" action you describe, but I couldn't see it as a great way of keeping your code clean without using template files...

Doing the "index.php" thing you describe also reduces URL readability, which can be a big thing, ever had to type out a URL that's like the one this forum's on?

No harm in sticking to good ol' separate files imho...

Just my 2 cents, Sorry if I got too much into application as opposed to coding since this is the wrong forum for it.
Link to comment
https://forums.phpfreaks.com/topic/28588-get-function/#findComment-130821
Share on other sites

if you want to do what you are doing and its only for a members system or something small and the links wont change much you can do something like this:

[code=php:0]
$idx = new Main;

class Main {

function Main(){ //this function will run auto
if(!isset($_GET['act'])){ $act = 'login'; }else{ $act = $_GET['act']; }

switch($act){
case 'login':
$this->login();
break;

//more cases in here

default:
$this->login(); //if nothing is entered go to default page, login
}
}

function login(){
echo <<<html
This is our login page!
html;
}

} //end Main class
[/code]

classes are great! if you dont no OOP i sugegst you start learning it becasue its useful!
Link to comment
https://forums.phpfreaks.com/topic/28588-get-function/#findComment-130847
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.