[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.
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.
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!
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.
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.
Note: The second parameter ($asnc) has been removed during my test phase.
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.
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..
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