Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 18:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[PHP problem] Calling an object's function with parameters

Discussion on [PHP problem] Calling an object's function with parameters within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
BigM''s Avatar
 
elite*gold: 11
Join Date: Nov 2009
Posts: 1,247
Received Thanks: 363
Question [PHP problem] Calling an object's function with parameters

Hey guys,

recently I got a problem with PHP on which I haven't found a solution yet. I'm calling a function out of a object, but there seems to be a problem regarding the parameters.

Object (very simplyfied):

PHP Code:
class HP{
    function 
preload_async($folders){
    
var_dump($folders);
    }

than, later on:

PHP Code:
$HP = new HP
if I want to call the function now in a part of my document:

PHP Code:
<?=$HP->preload_async(array('slide','store'))?>
the dump just throws out stuff like this:

PHP Code:
array(1) {
    [
0]=>
    
string(0""

Anyone got an idea why it isn't working? I'm quite common with PHP and did a lot of similar stuff and that's why I'm wondering this code won't work.

Thanks for you advise!
BigM' is offline  
Old 09/10/2013, 16:39   #2
 
Chrisomator's Avatar
 
elite*gold: 0
Join Date: Jan 2010
Posts: 109
Received Thanks: 2
Try to define the function's parameter as an array as default.

PHP Code:
class HP
    function 
preload_async($folders = array()){ 
    
var_dump($folders); 
    } 

Chrisomator is offline  
Old 09/10/2013, 16:53   #3
 
BigM''s Avatar
 
elite*gold: 11
Join Date: Nov 2009
Posts: 1,247
Received Thanks: 363
Quote:
Originally Posted by Chrisomator View Post
Try to define the function's parameter as an array as default.

PHP Code:
class HP
    function 
preload_async($folders = array()){ 
    
var_dump($folders); 
    } 

I tried this one as well, without any effect. To be precise, I firstly wondered about an error regarding a predefined parameter ($folders, $foo="bar") which weren't set correctly before discovering neither the first one is functionable.
BigM' is offline  
Old 09/10/2013, 17:21   #4



 
Sedrika's Avatar
 
elite*gold: 18
The Black Market: 103/0/0
Join Date: Sep 2009
Posts: 20,177
Received Thanks: 14,471
PHP Code:
class HP{
    function preload_async($folders){
    return var_dump($folders);
    }
}  
$HP = new HP();

//....

<?php
$HP
->preload_async(array('slide','store'));
?>
This should help you a bit.
Sedrika is offline  
Old 09/10/2013, 22:36   #5
 
BigM''s Avatar
 
elite*gold: 11
Join Date: Nov 2009
Posts: 1,247
Received Thanks: 363
Thanks Sedrika for your try to help me, but badly it didn't work. I'm totally confused about that, because I did (like I mentioned before) really a lot of PHP codes during the last years.. and the code above seems clearly having to work!
BigM' is offline  
Old 09/10/2013, 22:40   #6

 
Synatex's Avatar
 
elite*gold: 25
Join Date: Apr 2010
Posts: 1,009
Received Thanks: 316
Show us the code or do not. But please stop posting those half-baked code parts which do absolutely say nothing since there can still be a mistake within your main code.

I bet no one is here to steal or do some other curious stuff with it. However, we're no projectionists so we won't be able to help you as long as you do not provide us with some code which is getting used and the actual PHP error.
Synatex is offline  
Old 09/10/2013, 23:28   #7
 
BigM''s Avatar
 
elite*gold: 11
Join Date: Nov 2009
Posts: 1,247
Received Thanks: 363
It wasn't a question of code being stolen or copied, the code is simply placed in three diferent files and positions(index, functions & home .php) which caused me to serve the code in parts.
Here is a spoiler showing the whole function, the rest is the same as well in mine.


The function was originally coded to preload specific folders of images asyncronous or directly. I know it's not a pretty way to do this, but the explained error occured during my work to rewrite it.
BigM' is offline  
Old 09/11/2013, 00:09   #8

 
Synatex's Avatar
 
elite*gold: 25
Join Date: Apr 2010
Posts: 1,009
Received Thanks: 316
Still, as said in the topic above, post the whole code or do not. This piece of code does say nothing. I've replicated your top example with just like any common combination you can find and each one worked...

So I just apply to you again, please post the whole code including the object.

... and even if there are 3 files, why dont you copy the contents of those 3 into this topic? We're trying to help and all you provide is some basic structure, no reliable example. How should we help there..
Synatex is offline  
Reply


Similar Threads Similar Threads
Help me with calling a game function in DLL (crash)
05/12/2013 - General Coding - 1 Replies
Heya, Gonna make it short, my game crashes when i call my function, the address of the function is fine. I hope someone here can tell me what's wrong. Code: if(msg == "Cast4"){ typedef int ( __stdcall *Spellcast)(DWORD , DWORD); Spellcast castmyspell = (Spellcast)0x00B908F0; castmyspell(6, 0); }
Need some help calling function for height
07/27/2011 - Perfect World - 2 Replies
Hey there, for some reason I keep crashing upon trying to call this function and it's really pissing me off. I was wondering if somebody could give me some advice as to what I'm doing wrong :( The function is being called inside a function starting at address 0x465730 in PWI The function I'm looking for is called twice here, namely at 0x4657C7 and 0x465879. The code where it is called looks something like this: http://img94.imageshack.us/img94/9867/coordfuncti on.png Now, I'm...
Help, calling an ingame function
03/13/2010 - General Coding - 2 Replies
Im trying with my dll to set off the "set stat function". The one that u press when you add a stat point to str, dex or what ever. My goal is to make players able to set there Stats to whatever they use to have from an earlier saved point. So if you play against different sort of mobs or players you reform your stats to be suetable for that sertan task in just 1 second right where you stand. Im thinking this is very useful for many ppl here. So now i could use help with the actuall call of...
Help with calling this function!
03/13/2010 - 12Sky2 - 6 Replies
First off: sorry for my poor english! Im trying with my dll to set off the "set stat function". The one that u press when you add a stat point to str, dex or what ever. My goal is to make players able to set there Stats to whatever they use to have from an earlier saved point. So if you play against different sort of mobs or players you reform your stats to be suetable for that sertan task in just 1 second right where you stand. Im thinking this is very useful for many ppl here. So now i...
Calling function in a game
03/29/2009 - General Coding - 1 Replies
Hai guise, I'm a stupid morron but how can I make a hook in c++ that will use Gameplay::GetMoney(); to return the current amount of Gold I have? http://www.bilderkiste.org/show/original/0bba0c93 80a21de4810c1429cbc287c9/call.jpg



All times are GMT +2. The time now is 18:08.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.