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: 6622 | Odgovora: 7 ] > FB > Twit

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 - pre 243 meseci
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...
 
Odgovor na temu

noviKorisnik
Dejan Katašić
Novi Sad

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

Sajt: www.novikorisnik.net


+5 Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:07 - pre 243 meseci
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.
 
Odgovor na temu

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 - pre 243 meseci
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.
 
Odgovor na temu

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

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

Sajt: localhost


+5 Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 14:21 - pre 243 meseci
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]
 
Odgovor na temu

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 - pre 243 meseci
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/

 
Odgovor na temu

noviKorisnik
Dejan Katašić
Novi Sad

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

Sajt: www.novikorisnik.net


+5 Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 15:06 - pre 243 meseci
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();
?>

 
Odgovor na temu

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 - pre 243 meseci
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.
 
Odgovor na temu

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

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

Sajt: localhost


+5 Profil

icon Re: Content-Length of the file embedded in file itself03.05.2004. u 19:22 - pre 243 meseci
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..

 
Odgovor na temu

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

[ Pregleda: 6622 | Odgovora: 7 ] > FB > Twit

Postavi temu Odgovori

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