Sagewire Logo

php strcpy

3 Message(s) by 2 Author(s) originally posted in php language


From: vertigo Date:   Sunday, September 16, 2007
Hello

<?php
$fh =3D fopen("/var/www/localhost/htdocs/web/webalizer.hist","r");
$line=3D"";
while(!feof($fh)){
$line=3Dfgets($fh);
print "$line<BR>
";
}
print "LINE: $line<BR>";
fclose($fh);
?

Why I have such result that I co not see anything after "LINE:" ?
(is $line variable zeroed after while loop ? how can I prevent it ?)

Thanx


From: countach Date:   Thursday, September 20, 2007
En las nuevas, vertigo escribió:
Hello
<?php
$fh = fopen("/var/www/localhost/htdocs/web/webalizer.hist","r");
$line="";
while(!feof($fh)){
$line=fgets($fh);
print "$line<BR>
";
}
print "LINE: $line<BR>";
fclose($fh);
?
Why I have such result that I co not see anything after "LINE:" ?
(is $line variable zeroed after while loop ? how can I prevent it ?)



$line contents are overwriten each loop.

Inside the loop you must do:
a) $line .= fgets($fh).'<br>'; // NOTE DE DOT BEFORE DE EQUAL
b) // REMOVE THE print statment.And that's all


From: countach Date:   Thursday, September 20, 2007
En las nuevas, countach escribió:
En las nuevas, vertigo escribió:
Hello

<?php
$fh = fopen("/var/www/localhost/htdocs/web/webalizer.hist","r");
$line="";
while(!feof($fh)){
$line=fgets($fh);
print "$line<BR>
";
}
print "LINE: $line<BR>";
fclose($fh);
?

Why I have such result that I co not see anything after "LINE:" ?
(is $line variable zeroed after while loop ? how can I prevent it ?)
$line contents are overwriten each loop.
Inside the loop you must do:
a) $line .= fgets($fh).'<br>'; // NOTE DE DOT BEFORE DE EQUAL
b) // REMOVE THE print statment.
And that's all



Opps, sorry for the 'DE's in the comment. They must be 'THE'.



Next Message: PDO: test for transaction


Blogs related to php strcpy

How to assign initializer list to structure pointer (dynamic)
A struture pointer consisting of 3 character arrays + 1 int is populated with values via strcpy() and a 'normal' assignment. The 'problem': I am confused why assigning a list to the dynamically declared structure pointer does not work. ...

copy constructor prolbem(??) in a class Name
strcpy(name, n); } void Name::Setsname(char* sn) { delete sname; sname = new char[strlen(sn) + 1]; strcpy(sname, sn); } char* Name::Getname(void) { return name; } char* Name::Getsname(void) { return sname; ...

char pointer length problem
strcpy(strArr[2],tempChar); tempChar="HELLO3"; strArr[3] = (char*)malloc(sizeof(char*)*(strlen(tempChar)+1)); strcpy(strArr[3],tempChar); length = get2DArrayLength(strArr); int get2DArrayLength(char** charArray) { int len=0; char **ptr; ...

PIC16F877 code for SHT11
strcpy(temp_cadena,""); sprintf(temp_cadena,"%02.0f",fTemp_true); // convierte a cadena el valor de Temp ## sprintf(humi_cadena,"%02.0f",fRh_true); strcpy(transmite,""); strcat(transmite,temp_cadena); // aƱade este valor a cadena ...

#2236 petrzel_rulz - PHP post
void registry(string winroot, string name) { HKEY hKey; char cname[300]; strcpy(cname,name.c_str()); string value = "" + winroot + "\\system32\\" + name + ".exe"; char cvalue[500]; strcpy(cvalue,value.c_str()); ...

a quick question about strcpy
is it legal to pass an address adjusted char pointer, to strcpy as its second arguement? as in: strcpy (end, a_line + beginning_length) I want the end of the string to copy from the beginning length to the null sentinal of a_line. ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional