Jump to content

mmtalon

Members
  • Posts

    20
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mmtalon's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. First, I don't know if the code example is deprecated because of a later version of the document object model (DOM). Or, perhaps, the code is designed for a later version of DOM, where PHP 4.3.x won't support the newer version of DOM. I was hoping that someone would recognize the code as being to old or not new enough. I thought that the PHP server is what translate the javascript to the client computer and that the PHP server would ultimately be the problem. Do correct me if I am wrong on how javascript reaches the client computer.
  2. Can PHP 4.3.x support this document object code? [code] alert("bodyNode.firstChild.nodeName = " + bodyNode.firstChild.nodeName); [/code]
  3. To clarify, I thought that the array was a reference of the session variable when you create the session using the name of the particular variable. So I really learned something from you that is important to know. Thanks again!
  4. I thought wrong. The code worked after using your suggestion. Thank you jesirose so much for your help.
  5. I thought this code was initializing the array: for ($counter=0; $counter < 4; $counter++) { $count[$counter] = $v[$counter]; }
  6. Thank you. I'm taking a look at that right now.
  7. Still not working with that change. I'm looking for other examples now.
  8. I read the two mulitdimensional post below, however I could not draw a conclusion from them. [url=http://www.phpfreaks.com/forums/index.php/topic,119312.msg488542.html#msg488542 http://www.phpfreaks.com/forums/index.php/topic,119312.0.html] http://www.phpfreaks.com/forums/index.php/topic,119312.msg488542.html#msg488542 http://www.phpfreaks.com/forums/index.php/topic,119312.0.html [/url] I varified that the array is being stored properly by a session dump: [code] foreach ( $_SESSION as $key => $key_value ) { print "<li> $key = $key_value\n"; } [/code] dump result: X = Array - Where X is the name of my array($count). An example of my code is below. I tried to retrieving the array using the two foreach construct below. I must be doing something wrong. Please help. [code] session_start(); $_SESSION['count']; // tried session var init here $_SESSION['count'] = array(); // tried session array init here $v[0] = 489; $v[1] = 883; $v[2]= 350; $v[3] = 555; for ($counter=0; $counter < 4; $counter++) { $count[$counter] = $v[$counter]; } // this code result in successful output echo "count_0: " . $count[0]; echo "<p>count_1: $count[1]\n\r</p>"; echo "<p>count_2: $count[2]\n\r</p>"; echo "<p>count_3: $count[3]\n\r</p>"; $trans = $_SESSION['count']; // no extraction results from the following code: foreach ($trans[] as $key => $value ) { echo "<p> $key = $value\n</p>"; } foreach($_SESSION['count'][] as $var) { echo "this is a new count:". $var; } [/code]
  9. fert, I am still testing and you have gave me something to think about. At the same time I am looking at the created variable or function "$x('y');" as some kind of place holder. However, I better think twice about my testing after seeing your code you posted above. Does your book tell you explicitly what the code is doing? Thanks fert for the warnning and your input. I'll post whatever I find out if I thank it is helpful. Hi there MCP. $a("Alice") becomes myNameFunc("Alice") becomes "Bill and Alice" does seem to become one in the same. So it being call an expression might be the same as calling it a place holder(perhaps). I'm kind of clear on what it does and therefore I can make a decision if I should use it for the best results. I will check back periodically to see if anyone has any more info regarding this particular code. Thank again KingPhilip, MCP and fert for all the help.
  10. MCP, I'm still testing this out. I'm trying to figure out if "$a()" is a function, function-variable, a pointer or what. And what about the result from - $a("Bill");? I'm sure that I am barking up the right tree with you and KingPhilip's help. Thank. fert, I agree with you regarding how PHP use pointers for variables. And this is the same way that C++ use variable pointers. However, C and C++ use arrays and function pointers somewhat differently, at lease this is what I think. I am still a novice when it come to PHP or C and C++.
  11. MCP, This makes a lot of sense and possibly ties into my pointer theory. Thank you for pointing this snippet of code out to me, no pun intended. [quote]Note that the same works for variable names: Code: $a = "b"; $b = "Bob"; print $$a; will print "Bob", since the "$a" will evaluate to "b", and then the "$b" will evaluate to "Bob". Try it! Same works with functions: Code: $a = "myNameFunc"; function myNameFunc($name){   return "Bill and $name"; } echo $a("Alice"); will print out "Bill and Alice"[/quote]
  12. KingPhilip, this is over my head also. But just trying to get a grasp of it all. In doing so, I really appreciate your help. Thanks a mill.
  13. Thank you for your help KingPhilip. [quote]Okay, are you wanting to make functionName a function or a variable? because right now you have it set as a variable, but then checks to see if it is a function. [/quote] Is "$functionName" setup as a variable? If I can recall playing around with C++, this code could be acting as a pointer to the beginning of the function and copying another function to create a duplicate. Nevertheless, I never seen a function called using a pointer and parameters. I could be totally off base here, and that is why I am asking. But I am assuming that the developers are creating a function and is using function_exists call as an error handler. This is not the only time I have seen this code being used. I got the code example that I posted from the Xinha site [url=http://(http://xinha.python-hosting.com/changeset/622?format=diff)](http://xinha.python-hosting.com/changeset/622?format=diff)[/url], the HTML open source editor. Here's another example below that came from Drupal Developers [url=http://(http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/jareyero/image/image.gd2.inc?rev=1.2)](http://cvs.drupal.org/viewcvs/drupal/contributions/sandbox/jareyero/image/image.gd2.inc?rev=1.2)[/url], the web-based content management system. This example was not part of a class, however, it's using the same concept. [code] // Check image type  $image_details = _get_image_details($imagename);  $function = 'imageCreateFrom'.$image_details['type'];  if (function_exists($function))  {    $im = $function($imagename); [/code] Please do reply, KingPhilip, if you have the time, especially if I'm wrong about the pointer assumption. Thank you again for your consideration. P.S. I just read MCP's Post before posting this reply. [quote]What the class is aiming to do is avoid from having to hardcode all the different functions for all the different image types supported.[/quote] [quote]The $functionName($this->image) statement is perfectly valid. it will evaluate $functionName to, as in the running example, ImageCreateFromJPEG, which will then turn the actual function call into ImageCreateFromJPEG($this->image). [/quote] I will research this further because I am still in doubt regarding thoughts about this as mentioned above. So MCP, if you read this, please don't hesitate to respond. Thank you all so much for your time and clearification.
  14. I need help with understanding the following PHP code: [color=red][b]$functionName = 'ImageCreateFrom' . $this->type;[/b][/color] The code is part of a class function. A copy of the function is below and the code in question is above highlighted in red and bold. After this assignment, the code checks to see if a function "$functionName" exist and later assigns a class variable with the value of the "$functionName(class var)" function call. The dollar sign in front of the function seems strange to me. Q. can you create a function in this manner? Please help me understand and tell me where I can go to get more information with this code assignment. Thanks All. [code] function load($image)     {         $this->uid = md5($_SERVER['REMOTE_ADDR']);         $this->image = $image;         $this->_get_image_details($image);         $functionName = 'ImageCreateFrom' . $this->type; if(function_exists($functionName)) { $this->imageHandle = $functionName($this->image); }     } // End load [/code]
×
×
  • 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.