generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: require_once()

Previous Thread :: Next Thread 
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
11 Oct 2011 09:35 PM
Can you put 'GET's on URLs for require_once(), such as

require_once(something.php?id=1);

I'm asking this from a PHP perspective.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
11 Oct 2011 09:36 PM
what
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
11 Oct 2011 09:40 PM
In PHP's require_once() function, can you put extras onto the URL? Here's an example:

require_once("cool.php?coolness=1337");

Can you do that, or will it cause an error if you put the '?coolness=1337' on it?
Report Abuse
belial52 is not online. belial52
Joined: 10 Oct 2009
Total Posts: 8074
11 Oct 2011 09:57 PM
I don't see why you couldn't. Test it before you come here though, please.
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
11 Oct 2011 10:05 PM
I did. I got an error. I was more so coming to see if it was just me or if it was really because I can't be done.
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
12 Oct 2011 12:33 AM
What? It doesn't make any sense to pass that data to a require. A require is a _textual inclusion_, what do you pospose the said GET parameters are going to do exactly...?
Report Abuse
LocalDimensions is not online. LocalDimensions
Joined: 08 Oct 2011
Total Posts: 2929
12 Oct 2011 07:22 AM
@xLEGOx

maybe he wants to grab $_GET's from another page source?
Report Abuse
XlegoX is not online. XlegoX
Joined: 16 Jun 2008
Total Posts: 14955
12 Oct 2011 07:45 AM
Why would you do something so horribly inefficient (And incorrect) when you could just directly pass the data in with a variable?

You can Do that (Not with require, since that's not what require is for), but it would be very bad design to do so.
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
12 Oct 2011 08:40 AM
How can I pass data into an exterior file, xLEGOx? I'm new to PHP, so I guess that's something I have yet to learn.
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
12 Oct 2011 11:04 AM
You have two options:

file1.php:

    $sum = $a + $b

file2.php

    $a = 1
    $b = 2

    require('file1.php')

    print $sum //3

-----------------------------


file1.php:

    function sum($a, $b) {
        return $a + $b;
    }

file2.php

    require_once('file1.php');
    print sum(1, 2); //3
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
12 Oct 2011 02:14 PM
...I don't think you understand what I'm trying to do.
Report Abuse
TheCapacitor is not online. TheCapacitor
Joined: 19 Jan 2011
Total Posts: 7045
12 Oct 2011 02:22 PM
Well require() won't throw an error if you use _GET, but include() will - both of which don't function with _GET in the URL. So I doubt require_once won't.
Report Abuse
SCARFACIAL is not online. SCARFACIAL
Joined: 28 Jan 2010
Total Posts: 7970
12 Oct 2011 02:24 PM
No, you can't.

I'd personally try something like this:

define("ForceId" , 1);
require_once("something.php");

then in something.php just use a ternary statement to define the id you're getting.

$id = (defined(ForceId)) ? ForceId : $_GET['id'] ;

Or something among those lines.

Regards,
~Scarfacial
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
12 Oct 2011 03:12 PM
$_GET["some_value"] = "whatever";
require_once("derp.php");
Report Abuse
NXTBoy is not online. NXTBoy
Joined: 25 Aug 2008
Total Posts: 4533
12 Oct 2011 04:35 PM
> ...I don't think you understand what I'm trying to do.

...I don't think you understand what _you're_ trying to do. Your question doesn't make sense.

When you include a file, it behaves as if you copied and pasted the textual contents of the file into that location, outside of php tags. So when you include a PHP file, it is executed in the same scope as the page that includes it.
Report Abuse
NVI is not online. NVI
Joined: 11 Jan 2009
Total Posts: 4744
12 Oct 2011 07:31 PM
Or you can all shut up, as I've answered the original question.
Report Abuse
bballer13sn is not online. bballer13sn
Joined: 03 Jun 2009
Total Posts: 2490
13 Oct 2011 07:10 AM
Okay...I think I know how I can make this work now. Thanks for the help.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image