Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Content-Length of the file embedded in file itself

[es] :: PHP :: Content-Length of the file embedded in file itself

[ Pregleda: 2676 | Odgovora: 7 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Dag
Moscow

Član broj: 11879
Poruke: 97
*.Moscow.dial.rol.ru

Sajt: orwell.ru


Profil

icon Content-Length of the file embedded in file itself03.05.2004. u 13:25

Da li iko može da pomogne sa ovim:

Code:

<?php
    header ("Content-Length: ???");
?>
<html>
<head>
</head>
<body>

<?php print somFuncHere('parameter'); ?>

Text text text text text text text text
Text text text text text text text text

<?php print somFuncHere('parameter'); ?>

Text text text text text text text text
Text text text text text text text text

</body>
</html>


Nije problem ručno ali automatski (i tačno!) - problem. Neki loop ispada...
03.05.2004. u 13:25 

noviKorisnik

Član broj: 13216
Poruke: 4516
*.dialup.neobee.net.



Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:07
Ono što treba da se ispiše staviš u string, izmeriš dužinu stringa, pošalješ header, ispišeš string.

Druga varijanta bi išla verovatno preko baferovanja ispisa, ali to bolje da prokomentariše neko ko je to koristio, da sada ne nabadam.
03.05.2004. u 14:07 

Dag
Moscow

Član broj: 11879
Poruke: 97
*.Moscow.dial.rol.ru

Sajt: orwell.ru


Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:15
Ma ne mozhe to tako... da je tako jednostavno mislish da bih postovao pitanje? Ja u drugom fajlu pishem:
Code:

    bla bla
    $data=implode('',file($url));
     $s=strlen($data);
    bla bla

i on ne mozhe da prodje zato stho kountuje i samog sebe... kada to uradish s drugim fajlom, sve ok.
03.05.2004. u 14:15 

-zombie-
Tomica Jovanovic
freelance programmer
ni.ac.yu

Član broj: 4128
Poruke: 3448
*.beotel.net

Sajt: localhost


Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:21
Code:

<?php
    // sam početak skripte..
    ob_start();
?>

    // ostali php i html kod..

<?php
    $content = ob_get_content();
    ob_end_clean();
    header('Content-Length: '.strlen($content));
    echo $content;
    // kraj skripte..
?>



// edit: vidi pojašnjenje dve poruke niže..


[Ovu poruku je menjao -zombie- dana 03.05.2004. u 21:25 GMT]
03.05.2004. u 14:21 

Dag
Moscow

Član broj: 11879
Poruke: 97
*.Moscow.dial.rol.ru

Sajt: orwell.ru


Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:43
Nec'e to Tomo brate mili. Headers already sent ili i druge greshke daje... to je prvo shto sam pokushavao... a imam i provere Last Modified i svezhine ETaga...
Code:

<?php
    ob_start();
?>
<html>
<head>
</head>
<body>

<?php print somFuncHere('parameter'); ?>

Text text text text text text text text
Text text text text text text text text

<?php print somFuncHere('parameter'); ?>

Text text text text text text text text
Text text text text text text text text

</body>
</html>
<?php
    $content = ob_get_content();
    ob_end_flush();
    header('Content-Length: '.strlen($content));
    echo $content;
?>


Evo kakav mi je (ok) rezultat samo ja value pishem ruchno (imam funckiju: nacrtaj($doc,$cp,$clen); (clen - koji ruchno unosim))

http://orwell.ru/cgi-bin/headers.cgi?url=http://orwell.ru/

03.05.2004. u 14:43 

noviKorisnik

Član broj: 13216
Poruke: 4516
*.dialup.neobee.net.



Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 15:06
Koliko vidim u Manualu, ob_end_flush daje ispis bafera - pa nema smisla pozivati header nakon ob_end_flush, već pre toga, mislim.

Komentar iz Manuala
Citat:
Here is an easy way to get the header Content-Lenght.
<?
ob_start();
?>
Put HTML tags.
<?
$size=ob_get_length();
header("Content-Length: $size");
ob_end_flush();
?>
03.05.2004. u 15:06 

Dag
Moscow

Član broj: 11879
Poruke: 97
*.Moscow.dial.rol.ru

Sajt: orwell.ru


Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 15:35
Da. header mora da ide unutra a get da uzim contentS. I josh je kao poznato da on ne obrac'a pazhnju na headers already sents but anyway... negde kod mene sve to strashno kochi... neki iz include neshto se negde svidja tom ob.
03.05.2004. u 15:35 

-zombie-
Tomica Jovanovic
freelance programmer
ni.ac.yu

Član broj: 4128
Poruke: 3448
*.beotel.net

Sajt: localhost


Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 19:22
Citat:
noviKorisnik:
Koliko vidim u Manualu, ob_end_flush daje ispis bafera - pa nema smisla pozivati header nakon ob_end_flush, već pre toga, mislim.


da, lapsus, mislio sam na ob_end_clean(), mada je još bolje ovo što si ti dao..

03.05.2004. u 19:22 

[es] :: PHP :: Content-Length of the file embedded in file itself

[ Pregleda: 2676 | Odgovora: 7 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.