Jump to content

[SOLVED] Getting a variable to work in function params


whatshakin

Recommended Posts

I have this fuction which is inside a class:

 

public static function generateEmbedCode($callId, $width="425", $height="320", $swfobjectPath="SDK/js/swfobject.js", $inviteButton="1", $guestList="1", $observerMode="0", $displayName="$nick") {
Blah Blah
}

 

What i need to do is grab some info and place it into a variable for $displayName="$nick" using:

    $memberid = (int)$_COOKIE['memberID'];
    $sQuery = "SELECT * FROM `Profiles` WHERE `ID` = '$memberid'";
    $result = db_res($sQuery);
    	while ( $p_arr = mysql_fetch_array( $result ) ) {
	//get profile data
	$nick = $p_arr['NickName'];
}

 

But I can't get it to work, my question is how can I get a variable to work inside the params of a function?? i hope this makes sense.

 

Thanks

Thanks,

Here's the whole function:

	public static function generateEmbedCode($callId, $width="425", $height="320", $swfobjectPath="SDK/js/swfobject.js", $inviteButton="1", $guestList="1", $observerMode="0", $displayName="$nick") {
	$bodyCode = "<script type=\"text/javascript\" src=\"$swfobjectPath\"></script>\n".
				"<script type=\"text/javascript\">\n".
					"\tvar flashvars = {};\n".
					"\tflashvars.inviteButton = \"$inviteButton\";\n".
					"\tflashvars.guestList = \"$guestList\";\n".
					"\tflashvars.observerMode = \"$observerMode\";\n".
					"\tflashvars.displayName = \"$displayName\";\n".
					"\tvar params = {};\n".
					"\tparams.allowfullscreen = \"true\";\n".
					"\tparams.allowscriptaccess = \"always\";\n".
					"\tvar attributes = {};\n".
					"\tattributes.id = \"tbx_call\";\n".
					"\tswfobject.embedSWF(\"".API_Config::API_SERVER.TokBoxApi::$API_SERVER_CALL_WIDGET.$callId."\", \"widgetDiv\", \"$width\", \"$height\", \"9.0.115\", false, flashvars, params, attributes);\n".
				"</script>\n".
				"<div id=\"widgetDiv\">\n".
					"\t<a href=\"http://www.adobe.com/go/getflashplayer\">\n".
						"\t\t<img src=\"http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" alt=\"Get Adobe Flash player\" />\n".
					"\t</a>\n".
				"</div>\n";

	return $bodyCode;
}

 

So would I have to add something inside this function to get it to display properly?  Sorry I just really don't know

 

 

Function get called with arguments. eg;

 

foo('hello');

 

This calls the function foo and passes it the string hello.

 

When you call your function generateEmbedCode(), the last argument it requires is your display name.

 

Trying to set a default value as a variable within your function definition as you have done will not work.

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.