473,786 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2381
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
3321
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 problem comes when I try to parse a second page, the url of which, I have derived from an initial page. I cannot go directly to the second (target) page but from the initial page derive the url and put it in a string called $strTarget In one...
11
13725
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, there's an "Edit" link. So the page itself looks something like this: <HTML><HEAD><TITLE>blah</TITLE></HEAD><BODY> <!-- TEXT STARTS HERE --> <H1>Hello World!</H1> <P>More stuff here...</P>
3
4561
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. So I coded my little search engine, uploaded it and it didn't work with my host (Dreamhost.com): Warning: fopen(): URL file-access is disabled in the server
5
8841
by: Jae | last post by:
Real(const string &fileName) { FILE * myInputFile = fopen(fileName, "rt"); ..... fclose(myInputFile);
0
1666
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: http://groups.google.co.uk/groups/dir?lnk=od&h=en&sel=&x=sssssxsssq But if I delete a character from the end, fopen() failes after 20 sec and returns strange error:
1
3693
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 always returns a NULL pointer. The file exists. I have triple checked it a thousand times in the debugger, moreover I got the path using a standard windows open dialog. (And no, there are no additional spaces in the path or before or after it.)
3
3452
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 Apache on RedHat Enterprise Linux 4. I've verified (by looking in httpd.conf) that Apache is running as user "apache" and group "apache". So, that's the user/group that PHP
2
2376
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. $fp = fopen("D:\Software\\test.txt","r"); while($data = fgets($fp, 400)) echo $data; #--> Result OK
13
2105
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 grounds that "Too many values or values are not recognized "
0
9497
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.