By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,209 Members | 1,706 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,209 IT Pros & Developers. It's quick & easy.

fopen() - weird staff with '&'

P: n/a
Hi .. this is for sure the 1k question on fopen but maybe can someone
tell me this weird staff

if i'm writing:
$H = fopen($value,"r");
while(!feof($H))
{
$string = fgets($H,1024);
....
.... blabla
}
fclose($H);
it does not work. it comes never in the loop
Yeh i hear you say "umpf what a dude" please read further..

the file is readable and so on ... blabla

now my Solution and Question:
if i put a '&' reference bevor the fopen(..) like
$H = &fopen($value,"r")
all work how it should be ... quasi fine :)

i ask because i have nothing found e.g on http://de3.php.net or other
related sites about this staff.

Whats my fault or my bad approach

thanks and by Robert

PS: sorry for my crummy english
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Robert Schott wrote:
Hi .. this is for sure the 1k question on fopen but maybe can someone
tell me this weird staff

if i'm writing:
$H = fopen($value,"r");


you need some error-checking

if ($H === false) die("Unable to open $value.");

(snip)

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #2

P: n/a
>
you need some error-checking

if ($H === false) die("Unable to open $value.");

(snip)


Hi Pedro..
Thanks for your advise.
Problem is not that fopen($value) returns an 'false' $H rather return
it an $H that is not legal for the e.g feof($H)

If i put an '&' reference on fopen($value) it works fine so it must be
an problem with the reference model.

The test if($H === false) solve not the problem that $H is not legal.

maybe is it my system:
HP ia64 / debian / PHP/4.1.2

Im new in PHP (not in programming) and it took me some time to
encircle the problem. There are some other nasty things with deduced
classes and it is for sure the distribution of PHP for my system.

maybe can you check the following on your system (i have PHP only on
the ia64):

class A
{
function A()
{
print get_class($this);
}
}

class B extends A
{
function B()
{
$this->A();
}
}

$bla = new B();

It should print "B" but the $this is empty in A and it print nothing.
Only if i put an:
var $bla = NULL; in B it works how it should. The fact is only that
is no var declaration in B value or name are unimportant.

good luck
robert

PS: sorry for my crummy english
Jul 17 '05 #3

P: n/a
Robert Schott wrote:
if i'm writing:
$H = fopen($value,"r");
while(!feof($H))
{
$string = fgets($H,1024);
....
.... blabla
}
fclose($H);
it does not work. it comes never in the loop
Yeh i hear you say "umpf what a dude" please read further..


Do you get an error? If so, what is the error message exactly?
Jul 17 '05 #4

P: n/a
Robert Schott wrote:
maybe is it my system:
HP ia64 / debian / PHP/4.1.2

Im new in PHP (not in programming) and it took me some time to
encircle the problem. There are some other nasty things with deduced
classes and it is for sure the distribution of PHP for my system.

maybe can you check the following on your system (i have PHP only on
the ia64):
I'll try that ... but I can't tell you about classes, their inheritance
or other stuff; I don't do OOP.
I'm using a Pentium with Debian GNU/Linux

$ php -v
PHP 4.3.8 (cli) (built: Jul 15 2004 05:41:01)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

$ cat xx.php
<?php

class A {
function A() {
echo 'My class is: ', get_class($this), ".\n";
}
}

class B extends A {
function B() {
$this->A();
}
}

$bla = new B();
echo "Done!\n";
?>
It should print "B" but the $this is empty in A and it print nothing.


$ php xx.php
My class is: b.
Done!
--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.