473,836 Members | 1,586 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 2385
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
3326
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
13735
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
4562
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
8846
by: Jae | last post by:
Real(const string &fileName) { FILE * myInputFile = fopen(fileName, "rt"); ..... fclose(myInputFile);
0
1667
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
3454
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
2377
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
2116
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
9825
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10859
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
10560
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
10602
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
10260
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7795
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
6984
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5653
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...
3
3116
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.