Προς το περιεχόμενο

php echo problem


varathro

Προτεινόμενες αναρτήσεις

koita genikotera den mou aresei h function ayth (Asxeta oti o tropos pou pas na kaneis usercounters den einai aytos) alla an thes mia beltiosh ths function sou mporeis na xrhshmopoihseis thn parakato

 

>
<?php 
function readwritetofile () //Orismos function
{
//Onoma arxeiou
$myFile = "test.txt"; 		

// An to arxeio den yparxei to dimiourgei to diabazei kai to grafei allios mono to diabazei kai to grafei
$mode = (!file_exists($myFile))?'x+b':'w+b';		

/**
 * kalytera na apofeygoume to die giati den 
 * einai oti kalytero na koboume thn selida.
 */

//Anagnosh arxeiou
$filecontents = @file_get_contents($myFile);

//Anoigma arxeiou gia diabasma kai eggrafh (x+ || (w+
$fp = fopen($myFile, $mode);


//Apofygh tou filezise <= 0
$filesize = ((filesize($myFile)) <= 0)?1:filesize($myFile); 	

//Ayksish tou $filecontents kata ena	
++$filecontents; 

//Eggrafh tou $filecontents sto arxeio
fwrite($fp, $filecontents); 

//Klhsimo tou arxeiou / stream
fclose($fp);  

//Eggrafh tou $var sthn html
echo $filecontents;		
}

//Kalesma funtcion
readwritetofile(); 

?> 

 

EDIT:

sthn function ayth pou sou edosa exo mesa to echo genikotera apofeygo na exo mesa to echo synithos kano return oti thelo na emfaniso kai meta echo thn function.

Συνδέστε για να σχολιάσετε
Κοινοποίηση σε άλλες σελίδες

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...