/    Sign up×
Community /Pin to ProfileBookmark

Application Objects in PHP

Hey Everyone,

Looking for a way to do Application Objects ([URL=http://www.w3schools.com/asp/asp_applications.asp]like that of ASP[/URL]). Not to sure if that would be the correct name for it in PHP… but you could also call them server-wide variables. I want to avoid using MySQL for these calculations.

  • Eric
  • to post a comment
    PHP

    16 Comments(s)

    Copy linkTweet thisAlerts:
    @rch10007Apr 30.2006 — look at this and see if it's what youa re talking about:

    http://www.php.net/manual/en/language.variables.predefined.php
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorApr 30.2006 — $_ENV and $_SERVER looks promising... I haven't run a test on them yet.

    But... lets say I wanted to have an array of objects on my server's memory (ie: locations to characters on a game map... seen by all users/clients), what one would I use?

    EDIT: to make better sense... if I had two scripts (A.php and B.php), which declaration would allow the both scripts to see the variable.

    Also, I ran across this: http://zez.org/article/articleview/46/1/

    Are they asking to RE-compile the php binary before I use it? And isn't using that method a little dangerous... ?
    Copy linkTweet thisAlerts:
    @rch10007Apr 30.2006 — using $_SESSION['variable'] or $_COOKIE['variable'] would allow you to pass the variable to whatever page you wanted to. make sure to use session_start() at the top of any pages that use session variables.
    Copy linkTweet thisAlerts:
    @NogDogApr 30.2006 — Yeah, it sounds like something you'd want to use sessions for. See http://www.php.net/manual/en/ref.session.php if you want to learn more (perhaps more than you want ? ).
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorApr 30.2006 — Doesn't the $_COOKIE declaration send the varable through the network?

    I'm looking for something that is stored locally on the server's RAM.
    Copy linkTweet thisAlerts:
    @rch10007Apr 30.2006 — yes, but that may be important if you are going to need different variables set for each user.
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorApr 30.2006 — True - But these are global variables... All the users need the see the same data.
    Copy linkTweet thisAlerts:
    @rch10007Apr 30.2006 — go with $_SESSION[''] then, I was just pointing out the cookie variable in case you are going to need to pull info from an individual user. but if you don't need to pass info back and forth, don't.
    Copy linkTweet thisAlerts:
    @Daniel_TApr 30.2006 — True - But these are global variables... All the users need the see the same data.[/QUOTE]Then perhaps this is betters suited to a text file (if you can't use MySQL)? I imagine you could have access to all users' data if you had their SESSIDs, but it wouldn't be very practical...
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorApr 30.2006 — That was another idea... but I'm looking for speed.

    I think ASP may be the way to go on this one... because PHP just doesn't support this (with out a System V extension... which is [b]not[/b] available on Windows... )

    meh....
    Copy linkTweet thisAlerts:
    @Daniel_TMay 01.2006 — ... but I'm looking for speed ... because PHP just doesn't support this[/QUOTE]
    You could simply write some functions to send/retrieve variables from files. This wouldn't be slower than ASP, because that's what ASP would be doing anyways. It has to be storing those varibales SOMEWHERE ? (hint: temp files)
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorMay 02.2006 — They do store them somewhere... It stores it in the RAM.
    Copy linkTweet thisAlerts:
    @rch10007May 02.2006 — if RAM is the only storage facility, I hope you got lots of it!
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorMay 02.2006 — Well you're missing the idea.

    Of COURSE i'm going to save it to an SQL database... but why flood it with a bunch of minute details when I could send it one large one (buffer the small details into a RAM)? Wouldn't that be more effecient? (and these are minor details... so if the data is lost, no big deal)
    Copy linkTweet thisAlerts:
    @Stephen_PhilbinMay 02.2006 — If you're on a Windows box, they you'd probably be best using the .Net framework anyway.

    If you're looking to reduce speed [i]that[/i] much and it's "no big deal" if these variables are lost, then I'd suggest you ditch them all together. It's just an unnecessary work for the systems resources.

    If you're doing something like making an online multi player game (which is what it sounds like), then you don't want to be using either .Net or PHP. You'd want to be building a proper server application and client application in something like C/C++ (seeing as speed is of the essence) and have them connect via a stateful protocol (possibly also custom built).
    Copy linkTweet thisAlerts:
    @L0phtpDKauthorMay 02.2006 — Very true Stephen.

    I plan on doing that, but we're still prototyping so I'm trying to make the development time as quickly as possible (2 weeks from concept to release). This is only an attempt to gain more VC for the project.
    ×

    Success!

    Help @L0phtpDK spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...