logs archiveIRC Archive / Freenode / #php / 2006 / February / 17 / 1
caffinated
it's a moot point though, since any implementation of them is going to be a hackish mess.
Olek
hey guys, i seem to remember from a long time ago there was a single function that would get php to run a linux command and print the result to a webpage as if you'd typed it into the terminal manually but i cant remember its name, can anyone help?
caffinated
in php anyway
TML
Because the language itself contains no support for them
Which is why I said what I said.
Olek
its ruby equivilent would be IO.popen
Jonnay
Right, which is what I was lamenting.
TML
If this had been #haskell or something, I would have been more careful.
Olek: php.net/exec
caffinated
Olek: popen() exists in php as well.
TML
Pollita: You been through the new "Advanced Unix Programming" from AWP?
         

jcoby
is there a php function to convert unix newlines to windows newlines?
caffinated
jcoby: str_replace()
TML
jcoby: str_replace()
jcoby
heh
TML
<:O
Olek
thanks guys :)
TML
I have been "teh defeated"!
jcoby
ok, what if you don't know what format it's in? str_replace would double up on the newlines if it is already in windows format?
Jymmm
s/e/3/
TML
Jymmm: Thanks
jcoby: No, it'd do something very odd
jcoby
TML: right.. that's what i'm trying to avoid :)
TML
jcoby: \r\n would become: \r\r\n
EmprCezar
Does anyone know how to override a class method without extending the class? Kinda like function_override(). I'm trying to extend a CMS and I'm trying as hard as I can to avoid editing the "Core" code.
TML
Anyone else notice lots of lag of late?
spuds
how can I got to the next element in a foreach loop? like -> foreach($array as $value) if ($value == 'foo') skip to next element;
s/got/go
mfonda
spuds, continue;
TML
EmprCezar: You can't without doing something really evil such as runkit.
EmprCezar
What's runkit?
Solara
Anyone know if MDB2 supports pdo?
joe333
i want to create a function inside a class, and the function takes 2 arguments that reference variables, like this: $this->_myFxn(&$csvLine, &$this->bigArray); ...the function will extract data from the CSV string $csvLine into a temporary array, and then push that temporary array to $this->bigArray
how would i define the function and how would i call it? i'm not too familiar with using the & symbol
         

EmprCezar
TML I see, it's a php extension
spuds
mfonda, thanks!
TML
EmprCezar: An evil, evil creation that allows you to violate PHP like you're its 300 lb. prison cellmate.
joe333: You don't need a & on either of those.
mfonda
Solara, there is no PDO driver for mdb2
joe333
TML, but i don't want to pass the values of either variable... i just want to reference them
basically i just want to shorten 10 lines of code to 1 fxn call
TML
joe333: You misunderstand what & does.
myconid
how can I run function named function_($i).. if $i is orange, run function_orange, if $i is green, run function_green
joe333
i guess so... i thought it works the same way as c++ ...of course it's been years since i took a c++ class
TML
myconid: How did you get yourself in THAT mess?
dj_segfault
${funcname}()
TML
joe333: It absolutely is NOT even *close* to C++
joe333
TML, so how do you distinguish between passing a variable and passing a reference to a variable in php?
Solara
mfonda: Well MDB2 said it would support pdo before stable and its listed as stable now -.-
myconid
TML: I want a function to edit images.. so i need to open it,and save it..
TML
joe333: You can't pass a reference to a variable in the way you're thinking.
joe333: PHP doesn't have that kind of references
jcoby
myconid: "function_{$i}"($i)
EmprCezar
myconid: You can also use call_user_func('function_'.$i)
TML
myconid: Go on...
jcoby
myconid: you can also stick the function name in a var and call it via $funcname($i)
mfonda
Solara, do you see a PDO driver on pear.php.net or in CVS?
EmprCezar
myconid: I think there are about a thousand ways to do it
mfonda
Solara, I dont
joe333
TML, so if i try to shorten these 10 lines of code (repeated at least a dozen times in different parts of my class) into 1 fxn is it going to degrade performance due to all the added variable copies?
TML
dj_segfault: ${funcname}() doesn't work.
dj_segfault: Just as an FYI
Solara
mfonda: I was going for the wishful thinking approach
pc2
in apache log --[client 129.21.61.206] PHP Fatal error: Call to undefined function curl_init()
TML
joe333: It's unlikely that PHP's copy-on-write copying of variables is going to create a significant performance decrease.
pc2: You don't have curl
pc2
the line is
$ch = curl_init();
TML
pc2: You don't have curl
pc2
curl --version
curl 7.12.0 (i686-suse-linux) libcurl/7.12.0 OpenSSL/0.9.7d ipv6 zlib/1.2.1
TML
pc2: See how it says "Call to undefined function curl_init()"?
mfonda
myconid, $function = 'function_' . $i; $function();
TML
pc2: Your PHP doesn't have the curl extension.
pc2
TML - How can I check/test/fix that? I installed libcurl
TML
pc2: libcurl isn't a PHP extension
pc2: It's a C library
pc2
i ¦php4-curl ¦4.3.8 ¦4.3.8 ¦PHP4 Extension Module ¦ 35.2 kB¦
TML
joe333: $this->bigArray[] = $this->_myFxn(&$csvLine); // Shouldn't have any effect whatsoever.
pc2
That's from my distribution anyways.
TML
pc2: If you have php4-curl, then you need to make your PHP aware of it. Are you using the apache module?
joe333
TML, well then i might have a different problem... i want to reference one of the class's arrays inside this fxn... if i understand you correctly, then passing $this->bigArray as a fxn argument and adding to that array inside the fxn will only update the array within the scope of the fxn, and it won't update the class's array $this->bigArray ....or am i way off?
TML, nevermind...
pc2
TML - can I tell in htptd.conf?
TML
joe333: $this->foo changes the object-wide instance of foo
joe333: So if you want to modify $this->foo inside a class method, you don't need to pass it as an argument. Just call it from within the method.
joe333
i can just leave out the line: array_push($this->bigArray, $tmpArray); in the fxn and instead have the fxn return $tmpArray
TML
pc2: No
joe333: That would be my suggestion.
Oh, wait, it already was. :)
pc2: Do you know where your php.ini is?
joe333
TML, i understand that... my original idea was to make this function work for a few different class arrays, so i wouldn't have to create multiple fxns like _addToBigArray() and _addToLargeArray() and _addToGiantArray()
but i think i know how to work around it now
TML
joe333: <:I
joe333
thx for the help
pc2
TML - yes
TML
That's some variable naming scheme you've got there.
joe333
just an example ;)
TML
(Action) wonders how big an array has to become before joe333 calls it "Giant"
pc2: Are you using the apache module?
joe333
TML, actually, that brings up another question... is there a limit to the number of arrays i can nest?
TML
No
joe333
(Action) whew!
TML
But if you find yourself going more than 3, I submit that your code needs to be refactored
Deeply nested data structures are hard for humans to get right.
joe333
yeah well luckily i'm the only one who needs to get it
TML
...
joe333
and once it works i'll just forget it all
j/k
the real hard part will be when i try to convert this class to Ruby or Python... still haven't decided whether i'm going to move to Ruby on Rails or Django
pc2
TML - http://cainkar.com/tmp/php.ini
TML
pc2: Please, for the love of all things sacred, answer the damn question! Are. You. Using. The. Apache. Module?
pc2
TML - I don't know what that is :(
TML
pc2: Who installed PHP on your machine?
MarkR
Hi all
pc2
TML - distribution -- stock
TML
pc2: *Who*?
Not "from where".
WHO
pc2
TML - suse
TML - me
TML
pc2: I can tell you with 100% assurance that PHP doesn't come installed "stock" on SuSE. You installed PHP from YaST?
Is there a reason it takes you 5 minutes to answer every question?
pc2
TML - yes -- 20 people keep walking into my office. I apologize.
TML - yes, I used yast.
TML - You have my attention now :)
TML
pc2: What was the name of the package in yast that you installed to get PHP on your machine?
pc2
rpm -qa | grep php
php4-4.3.8-8.14
php4-curl-4.3.8-8.2
php4-mysql-4.3.8-8.2
Let me load yast and look.
TML
pc2: BTW, that URL you gave is a 404
pc2
TML - try http://cainkar.com/temp/php.ini
¦php4 ¦4.3.8 ¦4.3.8 ¦PHP4 Core Files ¦ 2.9 MB¦
i ¦php4-curl ¦4.3.8 ¦4.3.8 ¦PHP4 Extension Module ¦ 35.2 kB¦
that is from yast
TML
pc2: Please don't paste all of that here.
pc2
Sorry.
TML
So you installed php4, but not anything like mod_php4 or libapache-mod-php?
pc2
TML - correct
TML - just checked in yast
TML
pc2: Are you accessing your PHP scripts via the web, or are you using PHP as a command-line language?
pc2
TML - I have used many php programs before without issue (gallery2, etc.).
web.
TML
pc2: And you are the sole admin of this machine?
pc2
yes
TML
(Action) sighs and shakes his head
pc2
(Action) Did something bad.
TML
pc2: What does <?php php_sapi_name(); ?> say?
diederick
hi there, does anyone knows how I can run some script in the background? (i've to perform some action which take around the 30-60 sec., and I don't want the user to wait for that)
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 next »