Jump to content

SiC_Goat

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    K2+Nemesis+165

Profile Information

  • Gender
    Male
  • Location
    New York

SiC_Goat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Interesting idea, didn't know you could use call_user_func on static portions of an object that way. I'll probably just write a static property method that takes in a $name and return self::$name or something. Better than any non-solution I have so far.
  2. That is exactly what I was trying to work around. It just glares at me with dirty eyes
  3. Is there a way, without instantiating an object, to access a static property of a class based solely on a string? Class MyClass { public static $MyProperty = 'MyValue'; } $className = 'MyClass'; $classProp = /* magic */; In need of 'magic'
  4. I want to do something like function demoStub ( KeyPair $pair ) { foreach ( $pair as $k => $v ) { // magic } } demoStub ( "red" => "fish", "blue" => "fish", "one" => "fish", "two" => "fish" ); I'm fairly certain at this point that it is impossible to construct such a function as array is a language structure rather than a function type.
  5. I'm aware that array is a language construct and not a function, however I'm curious to the extend of the T_DOUBLE_ARROW token [read: =>] and it's usability in user functions. Is it possible to define a function that accepts 'k => v' key pair sets in the same manner of array? I'm trying to avoid having to 'foo ( array ( bar1 => bar2, bar3 => bar4 ) )' every time I want to call this specific function.
  6. Just as a follow up, I've gone the way of using Clone to facilitate what I need. Making it a session variable would be akin to just passing the same object to the next recurse, no change. Here is a sort of visual of what I'm doing $b = array ( 'cats' => 1, 'dogs' => 0 ); function a ( $b ) { if ( $b['cats'] == 1 ) { $b_sub = clone $b; $b_sub['deer'] = 2; a ( $b_sub ); } } The whole point was that I could modify '$b' in each child recursive tree while retaining its state for future recursing in the current recurse. It's uses are limited, but a near requirement for some of those uses.
  7. Is there a simple convention to pass an object by its dereference? I'd like something simpler than having to clone the object and then pass it. Furthermore, because this is a recursive method, I'd like to avoid any permanent changes to the data-set I'm looking at while recursing [the data-set is not part of the recursing function, just read and modified at various levels of the recursing; each recursive step should have its own copy of this data-set]
  8. If you don't want to escape all those quotes you can always do <? if ( $boolean ) { ?> Lots of html and stuff could go here like this<br /> <?= $var ?> is also a cool shortcut to embedding php into HTML without having to type out a whole lot. <img src="img.jpg" alt="nowai" /> <? } ?>
  9. Can you post an example of your code? shell_exec("ls -l") and other correctly typed commands with spaced arguments should work per shell_exec().
  10. To access post variables use the $_POST[] super-global array. if ($_POST['step'] == "sell") { switch($_POST['seller']) { // ... } } I also recommend both checking for valid and safe input as well as that there is input to begin with using isset(). Also, put quotes around attribute values in your html; <form method="POST" action="....
  11. I'm curious as to why you want to connect to port 4000 using TCP, as apposed to UDP. A quick google search told me TCP port 4000 is used by SkyDance, a backdoor program. Now I normally wouldn't look up something like this, but you say you know enough to be dangerous, and want to insert data that is sent at random intervals into a database... Anyhow, I really don't think PHP is the language to be using for something like this if I'm wrong about your intentions. Just because it has inherent MySQL functionality doesn't make it good to bridge databases with non-web based programs.
  12. I'm not quite sure how to read your code, it's a tad hard on the eyes. To upload a file and then access it through PHP set the enctype in the form tag to multipart/form-data and have one of your input fields type set to file. This will include the browse button and upload the files binary data. <form action="foobar.php" method="post" enctype="multipart/form-data"> <input type="file" name="myPic"/> <input type="submit" value="upload" /> </form> The file is then uploaded to the temp directory as defined by php's configuration. To access the file in the action script use the superglobal $_FILES[] where the index is the name of the input tag. In this case <? print_r ( $_FILES["myPic"] ); ?> would print out all the information about the uploaded file. Use filesystem functions to then read the file from the server's local filesytem.
  13. Well I found out the hard way that tar.gz is an incredible compression as the 5mb archive explodes out into a nice 30mb + directory. As soon as I get my XP disk back I'm planning on tossing Kubuntu onto a second partition and trying CGI and using .htaccess to define the install. I know I can put the php configuration from the httpd.conf into a .htaccess and it will still work on my Win32 install. Too bad I have that ugly 20mb quota
  14. My university currently provides storage for all IT students on a linux server running php 3.0.12, scary eh? Now is there any way I can take php4.4.4 source and have it run within my personally home dir and use the .htdocs instead of the apache conf file. The server is running apache 1.3.9
  15. Having your code in such a fashion isn't wrong, but it is bad style. It often creates overhead and wasted code. The best method to design any application, web or not, is to have the actual page action, or code executed when the page loads, control everything while seperate objects or methods actuall get the data. This makes it so if you later desire to change teh method in which you get data you don't have to rewrite teh whole page. You only have to rewrite the actual code that gets teh data. This is often refered to as encapsulation. Suppose, for example, you get the page name from a config file. $pageName = getPageName(); Then later you want to get it from a sql database. $pageName = getPageName(); The point where you actually get the page name never changed, though the code that returns the page name has. - Orca Site Admin, Furious Lobster
×
×
  • 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.