473,395 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

fopen() - weird staff with '&'

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
4 2363
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
>
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Bill | last post by:
For my personal use I am accessing a railway timetable page, parsing its contents and then sending brief relevant information as the subject line of an email to be read on a mobile phone. The...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
3
by: James | last post by:
Hi guys, I have been building a search engine here - not because I have plans of dethrowning Google but as a simple app upon which to develop a function set that I can use for other things. ...
5
by: Jae | last post by:
Real(const string &fileName) { FILE * myInputFile = fopen(fileName, "rt"); ..... fclose(myInputFile);
0
by: milan.topalov | last post by:
I'm having some strange problems using fopen() to fetch website content. It seems I can't open URL shorter then certain lenght. I can open this:...
1
by: carpediem | last post by:
Hi, I am developing an application in Borland C++ 6, one of my functions opens a file and loads it into the memory. I have never had problems with fopen, but this bug is really weird, fopen...
3
by: IamtheEvster | last post by:
Hi there, I'm using fopen for the first time and I know I'm running into a permissions problem, but I can't seem to resolve it and any help would be greatly appreciated. I'm running PHP5 and...
2
by: Giorgio Sam | last post by:
Hello there, WEIRD...fopen couldn't open any http file while it's working fine with any local file. I've tried the following: ________________________________________________________ 1. ...
13
by: Dave Rado | last post by:
Hi The W3C css validation service at http://jigsaw.w3.org/css-validator/ claims that: {font-family: "Book Antiqua", Palatino, "Times New Roman", "Times Roman" serif} is invalid on the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.