FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » this is my code i am not getting images throuh php script
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
this is my code i am not getting images throuh php script [message #176558] Mon, 09 January 2012 15:23 Go to next message
sritullimilli is currently offline  sritullimilli
Messages: 13
Registered: November 2011
Karma: 0
Junior Member
<?php
header("Content-type:image/jpeg");
$fp=fopen("F:/Mydocuments/Certificates/Passport/Passport.jpg","r");
echo fread($fp,filesize("F:/Mydocuments/Certificates/Passport/Passport.jpg");
?>
Re: this is my code i am not getting images throuh php script [message #176561 is a reply to message #176558] Mon, 09 January 2012 15:37 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 9, 3:23 pm, srikanth <sritullimi...@gmail.com> wrote:
> <?php
> header("Content-type:image/jpeg");
> $fp=fopen("F:/Mydocuments/Certificates/Passport/Passport.jpg","r");
> echo fread($fp,filesize("F:/Mydocuments/Certificates/Passport/Passport.jpg");
> ?>

Not surprising really since you have a syntax error (missing ")").
Re: this is my code i am not getting images throuh php script [message #176564 is a reply to message #176561] Mon, 09 January 2012 16:25 Go to previous messageGo to next message
Erwin Moller is currently offline  Erwin Moller
Messages: 228
Registered: September 2010
Karma: 0
Senior Member
On 1/9/2012 4:37 PM, Captain Paralytic wrote:
> On Jan 9, 3:23 pm, srikanth<sritullimi...@gmail.com> wrote:
>> <?php
>> header("Content-type:image/jpeg");
>> $fp=fopen("F:/Mydocuments/Certificates/Passport/Passport.jpg","r");
>> echo fread($fp,filesize("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>> ?>
>
> Not surprising really since you have a syntax error (missing ")").

Yes.
srikanth, to debug such pieces of code you can simply change the header to:
header("Content-type:text/html");

and see what it says.
(Or check the rrorlog if you have one up-and-running).

Regards,
Erwin Moller


--
"That which can be asserted without evidence, can be dismissed without
evidence."
-- Christopher Hitchens
Re: this is my code i am not getting images throuh php script [message #176568 is a reply to message #176564] Mon, 09 January 2012 17:35 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Erwin Moller wrote:
> On 1/9/2012 4:37 PM, Captain Paralytic wrote:
>> On Jan 9, 3:23 pm, srikanth<sritullimi...@gmail.com> wrote:
>>> <?php
>>> header("Content-type:image/jpeg");
>>> $fp=fopen("F:/Mydocuments/Certificates/Passport/Passport.jpg","r");
>>> echo
>>> fread($fp,filesize("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>> ?>
>>
>> Not surprising really since you have a syntax error (missing ")").
>
> Yes.
> srikanth, to debug such pieces of code you can simply change the header to:
> header("Content-type:text/html");
>
> and see what it says.
> (Or check the rrorlog if you have one up-and-running).
>
> Regards,
> Erwin Moller
>
>
The minimal code is something like

send_passport.php
-----------------
<?php
header("Content-Type: image/jpeg");
readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
?>
<<<...and no whitespace here!!!

I mistrust using things that are designed for text strings for binary files.
Re: this is my code i am not getting images throuh php script [message #176569 is a reply to message #176568] Mon, 09 January 2012 18:48 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 09.01.2012 18:35, schrieb The Natural Philosopher:
> The minimal code is something like
>
> send_passport.php
> -----------------
> <?php
> header("Content-Type: image/jpeg");
> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
> ?>
> <<<...and no whitespace here!!!
>
> I mistrust using things that are designed for text strings for
> binary files.

Why not leave off the ?> tag?

/Str.
Re: this is my code i am not getting images throuh php script [message #176570 is a reply to message #176569] Mon, 09 January 2012 19:33 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
M. Strobel wrote:
> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>> The minimal code is something like
>>
>> send_passport.php
>> -----------------
>> <?php
>> header("Content-Type: image/jpeg");
>> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>> ?>
>> <<<...and no whitespace here!!!
>>
>> I mistrust using things that are designed for text strings for
>> binary files.
>
> Why not leave off the ?> tag?
>

Is that php legal?

If so it would make life simpler


> /Str.
Re: this is my code i am not getting images throuh php script [message #176571 is a reply to message #176570] Mon, 09 January 2012 20:20 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 09.01.2012 20:33, schrieb The Natural Philosopher:
> M. Strobel wrote:
>> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>> The minimal code is something like
>>>
>>> send_passport.php
>>> -----------------
>>> <?php
>>> header("Content-Type: image/jpeg");
>>> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>> ?>
>>> <<<...and no whitespace here!!!
>>>
>>> I mistrust using things that are designed for text strings for
>>> binary files.
>>
>> Why not leave off the ?> tag?
>>
>
> Is that php legal?
>
> If so it would make life simpler
>
>
>> /Str.

I read somewhere Zend leaves it off in its code.

Works like a charm.

/Str.
Re: this is my code i am not getting images throuh php script [message #176572 is a reply to message #176571] Mon, 09 January 2012 20:38 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
M. Strobel wrote:
> Am 09.01.2012 20:33, schrieb The Natural Philosopher:
>> M. Strobel wrote:
>>> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>>> The minimal code is something like
>>>>
>>>> send_passport.php
>>>> -----------------
>>>> <?php
>>>> header("Content-Type: image/jpeg");
>>>> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>>> ?>
>>>> <<<...and no whitespace here!!!
>>>>
>>>> I mistrust using things that are designed for text strings for
>>>> binary files.
>>> Why not leave off the ?> tag?
>>>
>> Is that php legal?
>>
>> If so it would make life simpler
>>
>>
>>> /Str.
>
> I read somewhere Zend leaves it off in its code.
>
> Works like a charm.

Not too old to learn something, then.

I'll use that next time one of my 'code only' scripts blows up..


>
> /Str.
Re: this is my code i am not getting images throuh php script [message #176573 is a reply to message #176572] Mon, 09 January 2012 20:53 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 09.01.2012 21:38, schrieb The Natural Philosopher:
> M. Strobel wrote:
>> Am 09.01.2012 20:33, schrieb The Natural Philosopher:
>>> M. Strobel wrote:
>>>> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>>> > The minimal code is something like
>>>> >
>>>> > send_passport.php
>>>> > -----------------
>>>> > <?php
>>>> > header("Content-Type: image/jpeg");
>>>> > readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>>> > ?>
>>>> > <<<...and no whitespace here!!!
>>>> >
>>>> > I mistrust using things that are designed for text strings for
>>>> > binary files.
>>>> Why not leave off the ?> tag?
>>>>
>>> Is that php legal?
>>>
>>> If so it would make life simpler
>>>
>>>
>>>> /Str.
>>
>> I read somewhere Zend leaves it off in its code.
>>
>> Works like a charm.
>
> Not too old to learn something, then.
>
> I'll use that next time one of my 'code only' scripts blows up..
>
>
>>
>> /Str.

Just re-checked it, it is official, leave it off. It caused me
headaches in one project I took over, there were tons of files
included, and I always had unwanted newlines in file output.

Just omit the closing tag in php-only files, it's easier than the
ob_ functions.

/Str.
Re: this is my code i am not getting images throuh php script [message #176574 is a reply to message #176573] Mon, 09 January 2012 22:04 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 09-01-2012 21:53, M. Strobel wrote:
> Am 09.01.2012 21:38, schrieb The Natural Philosopher:
>> M. Strobel wrote:
>>> Am 09.01.2012 20:33, schrieb The Natural Philosopher:
>>>> M. Strobel wrote:
>>>> > Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>>> >> The minimal code is something like
>>>> >>
>>>> >> send_passport.php
>>>> >> -----------------
>>>> >> <?php
>>>> >> header("Content-Type: image/jpeg");
>>>> >> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>>> >> ?>
>>>> >> <<<...and no whitespace here!!!
>>>> >>
>>>> >> I mistrust using things that are designed for text strings for
>>>> >> binary files.
>>>> > Why not leave off the ?> tag?
>>>> >
>>>> Is that php legal?
>>>>
>>>> If so it would make life simpler
>>>>
>>>>
>>>> > /Str.
>>>
>>> I read somewhere Zend leaves it off in its code.
>>>
>>> Works like a charm.
>>
>> Not too old to learn something, then.
>>
>> I'll use that next time one of my 'code only' scripts blows up..
>>
>>
>>>
>>> /Str.
>
> Just re-checked it, it is official, leave it off. It caused me
> headaches in one project I took over, there were tons of files
> included, and I always had unwanted newlines in file output.
>
> Just omit the closing tag in php-only files, it's easier than the
> ob_ functions.
>
> /Str.

If you re-checked, could you also provide us with a link to where you
found that info?


--
Luuk
Re: this is my code i am not getting images throuh php script [message #176575 is a reply to message #176574] Mon, 09 January 2012 22:08 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 09.01.2012 23:04, schrieb Luuk:
> On 09-01-2012 21:53, M. Strobel wrote:
>> Am 09.01.2012 21:38, schrieb The Natural Philosopher:
>>> M. Strobel wrote:
>>>> Am 09.01.2012 20:33, schrieb The Natural Philosopher:
>>>> > M. Strobel wrote:
>>>> >> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>>> >>> The minimal code is something like
>>>> >>>
>>>> >>> send_passport.php
>>>> >>> -----------------
>>>> >>> <?php
>>>> >>> header("Content-Type: image/jpeg");
>>>> >>> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>>> >>> ?>
>>>> >>> <<<...and no whitespace here!!!
>>>> >>>
>>>> >>> I mistrust using things that are designed for text strings for
>>>> >>> binary files.
>>>> >> Why not leave off the ?> tag?
>>>> >>
>>>> > Is that php legal?
>>>> >
>>>> > If so it would make life simpler
>>>> >
>>>> >
>>>> >> /Str.
>>>>
>>>> I read somewhere Zend leaves it off in its code.
>>>>
>>>> Works like a charm.
>>>
>>> Not too old to learn something, then.
>>>
>>> I'll use that next time one of my 'code only' scripts blows up..
>>>
>>>
>>>>
>>>> /Str.
>>
>> Just re-checked it, it is official, leave it off. It caused me
>> headaches in one project I took over, there were tons of files
>> included, and I always had unwanted newlines in file output.
>>
>> Just omit the closing tag in php-only files, it's easier than the
>> ob_ functions.
>>
>> /Str.
>
> If you re-checked, could you also provide us with a link to where you
> found that info?
>
>
search string was php closing tag

http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp

/Str.
ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176585 is a reply to message #176575] Tue, 10 January 2012 10:58 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 09-01-2012 23:08, M. Strobel wrote:
> Am 09.01.2012 23:04, schrieb Luuk:
>> On 09-01-2012 21:53, M. Strobel wrote:
>>> Just omit the closing tag in php-only files, it's easier than the
>>> ob_ functions.
>>>
>>> /Str.
>>
>> If you re-checked, could you also provide us with a link to where you
>> found that info?
>>
>>
> search string was php closing tag
>
> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>
> /Str.

damn, they actually documented this UGLY feature ;)

--
Luuk
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176586 is a reply to message #176585] Tue, 10 January 2012 11:15 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 10, 10:58 am, Luuk <L...@invalid.lan> wrote:
>> search string was php closing tag
>
>> http://www.php.net/manual/en/language.basic-syntax.instruction-separa...
>
>> /Str.
>
> damn, they actually documented this UGLY feature ;)

Not only that, but they even recommend it "and in some cases omitting
it is helpful".
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176588 is a reply to message #176585] Tue, 10 January 2012 12:33 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Luuk wrote:
> On 09-01-2012 23:08, M. Strobel wrote:
>> Am 09.01.2012 23:04, schrieb Luuk:
>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> Just omit the closing tag in php-only files, it's easier than the
>>>> ob_ functions.
>>>>
>>>> /Str.
>>> If you re-checked, could you also provide us with a link to where you
>>> found that info?
>>>
>>>
>> search string was php closing tag
>>
>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>
>> /Str.
>
> damn, they actually documented this UGLY feature ;)
>
Ugly, but damed usefull as my editor has a habit of adding an extra
newline to the end of text files.
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176589 is a reply to message #176586] Tue, 10 January 2012 12:34 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Captain Paralytic wrote:
> On Jan 10, 10:58 am, Luuk <L...@invalid.lan> wrote:
>>> search string was php closing tag
>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separa...
>>> /Str.
>> damn, they actually documented this UGLY feature ;)
>
> Not only that, but they even recommend it "and in some cases omitting
> it is helpful".
Which it is in any case where whitespace is something the browser will
*not* ignore..
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176591 is a reply to message #176588] Tue, 10 January 2012 12:54 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
> Luuk wrote:
>> On 09-01-2012 23:08, M. Strobel wrote:
>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> > Just omit the closing tag in php-only files, it's easier than the
>>>> > ob_ functions.
>>>> >
>>>> > /Str.
>>>> If you re-checked, could you also provide us with a link to where you
>>>> found that info?
>>>>
>>>>
>>> search string was php closing tag
>>>
>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>
>>>
>>> /Str.
>>
>> damn, they actually documented this UGLY feature ;)
>>
> Ugly, but damed usefull as my editor has a habit of adding an extra
> newline to the end of text files.
>

So get a good editor.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176592 is a reply to message #176589] Tue, 10 January 2012 13:24 Go to previous messageGo to next message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma: 0
Senior Member
On Jan 10, 12:34 pm, The Natural Philosopher <t...@invalid.invalid>
wrote:
> Captain Paralytic wrote:
>> On Jan 10, 10:58 am, Luuk <L...@invalid.lan> wrote:
>>>> search string was php closing tag
>>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separa....
>>>> /Str.
>>> damn, they actually documented this UGLY feature ;)
>
>> Not only that, but they even recommend it "and in some cases omitting
>> it is helpful".
>
> Which it is in any case where  whitespace is something the browser will
> *not* ignore..

So it's not "case sensitive" :-)
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176593 is a reply to message #176591] Tue, 10 January 2012 16:16 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 10.01.2012 13:54, schrieb Jerry Stuckle:
> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>> Luuk wrote:
>>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> > On 09-01-2012 21:53, M. Strobel wrote:
>>>> >> Just omit the closing tag in php-only files, it's easier
>>>> >> than the
>>>> >> ob_ functions.
>>>> >>
>>>> >> /Str.
>>>> > If you re-checked, could you also provide us with a link to
>>>> > where you
>>>> > found that info?
>>>> >
>>>> >
>>>> search string was php closing tag
>>>>
>>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>>
>>>>
>>>>
>>>> /Str.
>>>
>>> damn, they actually documented this UGLY feature ;)
>>>
>> Ugly, but damed usefull as my editor has a habit of adding an
>> extra
>> newline to the end of text files.
>>
>
> So get a good editor.
>

Now why should he "get a good editor" if he can omit the closing tag?

/Str.
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176597 is a reply to message #176593] Tue, 10 January 2012 19:56 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 1/10/2012 11:16 AM, M. Strobel wrote:
> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>> Luuk wrote:
>>>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> > Am 09.01.2012 23:04, schrieb Luuk:
>>>> >> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>> Just omit the closing tag in php-only files, it's easier
>>>> >>> than the
>>>> >>> ob_ functions.
>>>> >>>
>>>> >>> /Str.
>>>> >> If you re-checked, could you also provide us with a link to
>>>> >> where you
>>>> >> found that info?
>>>> >>
>>>> >>
>>>> > search string was php closing tag
>>>> >
>>>> > http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >
>>>> >
>>>> >
>>>> > /Str.
>>>>
>>>> damn, they actually documented this UGLY feature ;)
>>>>
>>> Ugly, but damed usefull as my editor has a habit of adding an
>>> extra
>>> newline to the end of text files.
>>>
>>
>> So get a good editor.
>>
>
> Now why should he "get a good editor" if he can omit the closing tag?
>
> /Str.

Because leaving off the close tag can cause problems later when someone
else edits the site, assuming close tags are there.

And leaving off a closing tag to get round an editor problem is just
plain sloppy programming. But we already know certain people here don't
care about that.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176598 is a reply to message #176597] Tue, 10 January 2012 21:08 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 10.01.2012 20:56, schrieb Jerry Stuckle:
> On 1/10/2012 11:16 AM, M. Strobel wrote:
>> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> Luuk wrote:
>>>> > On 09-01-2012 23:08, M. Strobel wrote:
>>>> >> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>> than the
>>>> >>>> ob_ functions.
>>>> >>>>
>>>> >>>> /Str.
>>>> >>> If you re-checked, could you also provide us with a link to
>>>> >>> where you
>>>> >>> found that info?
>>>> >>>
>>>> >>>
>>>> >> search string was php closing tag
>>>> >>
>>>> >> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >>
>>>> >>
>>>> >>
>>>> >>
>>>> >> /Str.
>>>> >
>>>> > damn, they actually documented this UGLY feature ;)
>>>> >
>>>> Ugly, but damed usefull as my editor has a habit of adding an
>>>> extra
>>>> newline to the end of text files.
>>>>
>>>
>>> So get a good editor.
>>>
>>
>> Now why should he "get a good editor" if he can omit the
>> closing tag?
>>
>> /Str.
>
> Because leaving off the close tag can cause problems later when
> someone else edits the site, assuming close tags are there.
>
> And leaving off a closing tag to get round an editor problem is
> just plain sloppy programming. But we already know certain
> people here don't care about that.
>
He has no editor problem, he can leave the closing tag off. Don't
send him off in a goose chase.

I knew who would not be comfortable with this easy solution.

/Str.
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176599 is a reply to message #176598] Tue, 10 January 2012 21:11 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
M. Strobel wrote:
> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>> On 1/10/2012 11:16 AM, M. Strobel wrote:
>>> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>>> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> > Luuk wrote:
>>>> >> On 09-01-2012 23:08, M. Strobel wrote:
>>>> >>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>>> than the
>>>> >>>>> ob_ functions.
>>>> >>>>>
>>>> >>>>> /Str.
>>>> >>>> If you re-checked, could you also provide us with a link to
>>>> >>>> where you
>>>> >>>> found that info?
>>>> >>>>
>>>> >>>>
>>>> >>> search string was php closing tag
>>>> >>>
>>>> >>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>>
>>>> >>> /Str.
>>>> >> damn, they actually documented this UGLY feature ;)
>>>> >>
>>>> > Ugly, but damed usefull as my editor has a habit of adding an
>>>> > extra
>>>> > newline to the end of text files.
>>>> >
>>>> So get a good editor.
>>>>
>>> Now why should he "get a good editor" if he can omit the
>>> closing tag?
>>>
>>> /Str.
>> Because leaving off the close tag can cause problems later when
>> someone else edits the site, assuming close tags are there.
>>
>> And leaving off a closing tag to get round an editor problem is
>> just plain sloppy programming. But we already know certain
>> people here don't care about that.
>>
> He has no editor problem, he can leave the closing tag off. Don't
> send him off in a goose chase.
>
> I knew who would not be comfortable with this easy solution.
>
Only because

(a) he didn't know it
and
(b) I said it was useful.


NOTHING is easier than typing a ?> and then following it with a carriage
return..


> /Str.
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176600 is a reply to message #176599] Tue, 10 January 2012 21:23 Go to previous messageGo to next message
Richard is currently offline  Richard
Messages: 1
Registered: January 2012
Karma: 0
Junior Member
The Natural Philosopher <tnp(at)invalid(dot)invalid> writes:

> M. Strobel wrote:
>> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>>> On 1/10/2012 11:16 AM, M. Strobel wrote:
>>>> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>>> > On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> >> Luuk wrote:
>>>> >>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> >>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>>>> than the
>>>> >>>>>> ob_ functions.
>>>> >>>>>>
>>>> >>>>>> /Str.
>>>> >>>>> If you re-checked, could you also provide us with a link to
>>>> >>>>> where you
>>>> >>>>> found that info?
>>>> >>>>>
>>>> >>>>>
>>>> >>>> search string was php closing tag
>>>> >>>>
>>>> >>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>>
>>>> >>>> /Str.
>>>> >>> damn, they actually documented this UGLY feature ;)
>>>> >>>
>>>> >> Ugly, but damed usefull as my editor has a habit of adding an
>>>> >> extra
>>>> >> newline to the end of text files.
>>>> >>
>>>> > So get a good editor.
>>>> >
>>>> Now why should he "get a good editor" if he can omit the
>>>> closing tag?
>>>>
>>>> /Str.
>>> Because leaving off the close tag can cause problems later when
>>> someone else edits the site, assuming close tags are there.
>>>
>>> And leaving off a closing tag to get round an editor problem is
>>> just plain sloppy programming. But we already know certain
>>> people here don't care about that.
>>>
>> He has no editor problem, he can leave the closing tag off. Don't
>> send him off in a goose chase.
>>
>> I knew who would not be comfortable with this easy solution.
>>
> Only because
>
> (a) he didn't know it
> and
> (b) I said it was useful.
>
> NOTHING is easier than typing a ?> and then following it with a carriage
> return..

How horrible. Are people really suggesting this hard to spot (when you
dont know it) hack as a way to develop code? Leaving off closing
tags?!?!?
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176601 is a reply to message #176600] Tue, 10 January 2012 21:31 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Richard wrote:
> The Natural Philosopher <tnp(at)invalid(dot)invalid> writes:
>
>> M. Strobel wrote:
>>> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>>>> On 1/10/2012 11:16 AM, M. Strobel wrote:
>>>> > Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>>> >> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> >>> Luuk wrote:
>>>> >>>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> >>>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>>>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>>>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>>>>> than the
>>>> >>>>>>> ob_ functions.
>>>> >>>>>>>
>>>> >>>>>>> /Str.
>>>> >>>>>> If you re-checked, could you also provide us with a link to
>>>> >>>>>> where you
>>>> >>>>>> found that info?
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>> search string was php closing tag
>>>> >>>>>
>>>> >>>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>>
>>>> >>>>> /Str.
>>>> >>>> damn, they actually documented this UGLY feature ;)
>>>> >>>>
>>>> >>> Ugly, but damed usefull as my editor has a habit of adding an
>>>> >>> extra
>>>> >>> newline to the end of text files.
>>>> >>>
>>>> >> So get a good editor.
>>>> >>
>>>> > Now why should he "get a good editor" if he can omit the
>>>> > closing tag?
>>>> >
>>>> > /Str.
>>>> Because leaving off the close tag can cause problems later when
>>>> someone else edits the site, assuming close tags are there.
>>>>
>>>> And leaving off a closing tag to get round an editor problem is
>>>> just plain sloppy programming. But we already know certain
>>>> people here don't care about that.
>>>>
>>> He has no editor problem, he can leave the closing tag off. Don't
>>> send him off in a goose chase.
>>>
>>> I knew who would not be comfortable with this easy solution.
>>>
>> Only because
>>
>> (a) he didn't know it
>> and
>> (b) I said it was useful.
>>
>> NOTHING is easier than typing a ?> and then following it with a carriage
>> return..
>
> How horrible. Are people really suggesting this hard to spot (when you
> dont know it) hack as a way to develop code? Leaving off closing
> tags?!?!?


It's not a 'closing tag' : its a switch to tell php to drop back into
'spit out the source file raw' mode.

If you don't ever want it to do that...it seems a valid reasonable and
apparently valid-in-terms-of-the-language-as-specified way to do it.

If the spec says its intrinsic to the language, a feature, it can't be
a hack can it?

How many people add semicolons to the last line of a CSS style block
definition?
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176602 is a reply to message #176601] Tue, 10 January 2012 21:45 Go to previous messageGo to next message
M. Strobel is currently offline  M. Strobel
Messages: 386
Registered: December 2011
Karma: 0
Senior Member
Am 10.01.2012 22:31, schrieb The Natural Philosopher:
> Richard wrote:
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> writes:
>>
>>> M. Strobel wrote:
>>>> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>>>> > On 1/10/2012 11:16 AM, M. Strobel wrote:
>>>> >> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>>> >>> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> >>>> Luuk wrote:
>>>> >>>>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> >>>>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>>>>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>>>>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>>>>>> than the
>>>> >>>>>>>> ob_ functions.
>>>> >>>>>>>>
>>>> >>>>>>>> /Str.
---cut
>>>> >>>>>> /Str.
>>>> >>>>> damn, they actually documented this UGLY feature ;)
>>>> >>>>>
>>>> >>>> Ugly, but damed usefull as my editor has a habit of
>>>> >>>> adding an
>>>> >>>> extra
>>>> >>>> newline to the end of text files.
>>>> >>>>
>>>> >>> So get a good editor.
>>>> >>>
>>>> >> Now why should he "get a good editor" if he can omit the
>>>> >> closing tag?
>>>> >>
>>>> >> /Str.
>>>> > Because leaving off the close tag can cause problems later when
>>>> > someone else edits the site, assuming close tags are there.
>>>> >
>>>> > And leaving off a closing tag to get round an editor problem is
>>>> > just plain sloppy programming. But we already know certain
>>>> > people here don't care about that.
>>>> >
>>>> He has no editor problem, he can leave the closing tag off.
>>>> Don't
>>>> send him off in a goose chase.
>>>>
>>>> I knew who would not be comfortable with this easy solution.
>>>>
>>> Only because
>>>
>>> (a) he didn't know it
>>> and
>>> (b) I said it was useful.
>>>
>>> NOTHING is easier than typing a ?> and then following it with
>>> a carriage
>>> return..
>>
>> How horrible. Are people really suggesting this hard to spot
>> (when you
>> dont know it) hack as a way to develop code? Leaving off closing
>> tags?!?!?
>
>
> It's not a 'closing tag' : its a switch to tell php to drop back
> into 'spit out the source file raw' mode.

I think of it in terms of HMTL tags <?php ?>

Everything between the tags (including them) is replaced by an
PHP eval of the contents.

> If you don't ever want it to do that...it seems a valid
> reasonable and apparently
> valid-in-terms-of-the-language-as-specified way to do it.
>
> If the spec says its intrinsic to the language, a feature, it
> can't be a hack can it?

I subscribe to that.

> How many people add semicolons to the last line of a CSS style
> block definition?

/Str.
Re: ommiting closeing tag in PHP [Re: this is my code i am not getting images throuh php script] [message #176603 is a reply to message #176601] Tue, 10 January 2012 22:02 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 10-01-2012 22:31, The Natural Philosopher wrote:
> Richard wrote:
>> The Natural Philosopher <tnp(at)invalid(dot)invalid> writes:
>>
>>> M. Strobel wrote:
>>>> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>>>> > On 1/10/2012 11:16 AM, M. Strobel wrote:
>>>> >> Am 10.01.2012 13:54, schrieb Jerry Stuckle:
>>>> >>> On 1/10/2012 7:33 AM, The Natural Philosopher wrote:
>>>> >>>> Luuk wrote:
>>>> >>>>> On 09-01-2012 23:08, M. Strobel wrote:
>>>> >>>>>> Am 09.01.2012 23:04, schrieb Luuk:
>>>> >>>>>>> On 09-01-2012 21:53, M. Strobel wrote:
>>>> >>>>>>>> Just omit the closing tag in php-only files, it's easier
>>>> >>>>>>>> than the
>>>> >>>>>>>> ob_ functions.
>>>> >>>>>>>>
>>>> >>>>>>>> /Str.
>>>> >>>>>>> If you re-checked, could you also provide us with a link to
>>>> >>>>>>> where you
>>>> >>>>>>> found that info?
>>>> >>>>>>>
>>>> >>>>>>>
>>>> >>>>>> search string was php closing tag
>>>> >>>>>>
>>>> >>>>>> http://www.php.net/manual/en/language.basic-syntax.instruction-separation.p hp
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>>>
>>>> >>>>>> /Str.
>>>> >>>>> damn, they actually documented this UGLY feature ;)
>>>> >>>>>
>>>> >>>> Ugly, but damed usefull as my editor has a habit of adding an
>>>> >>>> extra
>>>> >>>> newline to the end of text files.
>>>> >>>>
>>>> >>> So get a good editor.
>>>> >>>
>>>> >> Now why should he "get a good editor" if he can omit the
>>>> >> closing tag?
>>>> >>
>>>> >> /Str.
>>>> > Because leaving off the close tag can cause problems later when
>>>> > someone else edits the site, assuming close tags are there.
>>>> >
>>>> > And leaving off a closing tag to get round an editor problem is
>>>> > just plain sloppy programming. But we already know certain
>>>> > people here don't care about that.
>>>> >
>>>> He has no editor problem, he can leave the closing tag off. Don't
>>>> send him off in a goose chase.
>>>>
>>>> I knew who would not be comfortable with this easy solution.
>>>>
>>> Only because
>>>
>>> (a) he didn't know it
>>> and
>>> (b) I said it was useful.
>>>
>>> NOTHING is easier than typing a ?> and then following it with a carriage
>>> return..
>>
>> How horrible. Are people really suggesting this hard to spot (when you
>> dont know it) hack as a way to develop code? Leaving off closing
>> tags?!?!?
>
>
> It's not a 'closing tag' : its a switch to tell php to drop back into
> 'spit out the source file raw' mode.
>

it's NOT a switch to tell php to drop back into some other mode...

> If you don't ever want it to do that...it seems a valid reasonable and
> apparently valid-in-terms-of-the-language-as-specified way to do it.
>

yes, something is specified

> If the spec says its intrinsic to the language, a feature, it can't be
> a hack can it?
>

it's not a hack

> How many people add semicolons to the last line of a CSS style block
> definition?

i recently installed drupal on a (test)system

when i do this:

cd ....drupal
$ grep -lir '?>' * | wc -l
124
$ find * -name "*.php" -type f | wc -l
151

(124 files with (at-least 1) closing tag,
151 files with the extension '.php')

and not even all php-files have the '.php' extension.....

$ grep -lr '<?php' * | wc -l
1000

(1000 files with the php-opening-tag)

so, some 'programmers' seem to RELY on this behaviour ;-(


--
Luuk
Re: this is my code i am not getting images throuh php script [message #176616 is a reply to message #176570] Wed, 11 January 2012 14:51 Go to previous messageGo to next message
Arno Welzel is currently offline  Arno Welzel
Messages: 317
Registered: October 2011
Karma: 0
Senior Member
The Natural Philosopher, 2012-01-09 20:33:

> M. Strobel wrote:
>> Am 09.01.2012 18:35, schrieb The Natural Philosopher:
>>> The minimal code is something like
>>>
>>> send_passport.php
>>> -----------------
>>> <?php
>>> header("Content-Type: image/jpeg");
>>> readfile("F:/Mydocuments/Certificates/Passport/Passport.jpg");
>>> ?>
>>> <<<...and no whitespace here!!!
>>>
>>> I mistrust using things that are designed for text strings for
>>> binary files.
>>
>> Why not leave off the ?> tag?
>>
>
> Is that php legal?

Yes.

> If so it would make life simpler

That's the reason, why this is often recommended.


--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Re: ommiting closeing tag in PHP [message #176655 is a reply to message #176600] Mon, 16 January 2012 00:30 Go to previous message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
Richard wrote:

> The Natural Philosopher <tnp(at)invalid(dot)invalid> writes:
>> M. Strobel wrote:
>>> Am 10.01.2012 20:56, schrieb Jerry Stuckle:
>>>> And leaving off a closing tag to get round an editor problem is
>>>> just plain sloppy programming. But we already know certain
>>>> people here don't care about that.
>>> He has no editor problem, he can leave the closing tag off. Don't
>>> send him off in a goose chase.
>>>
>>> I knew who would not be comfortable with this easy solution.
>>
>> Only because
>>
>> (a) he didn't know it
>> and
>> (b) I said it was useful.
>>
>> NOTHING is easier than typing a ?> and then following it with a carriage
>> return..
>
> How horrible. Are people really suggesting this hard to spot (when you
> dont know it) hack as a way to develop code? Leaving off closing
> tags?!?!?

Your keyboard is borken.

What exactly is your problem with avoiding the problem caused by adding the
"closing tag"? It is the *P*HP *H*ypertext *P*reprocessor. It is
*supposed* to output any character outside of <?php … ?> sections.


PointedEars
--
Sometimes, what you learn is wrong. If those wrong ideas are close to the
root of the knowledge tree you build on a particular subject, pruning the
bad branches can sometimes cause the whole tree to collapse.
-- Mike Duffy in cljs, <news:Xns9FB6521286DB8invalidcom(at)94(dot)75(dot)214(dot)39>
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: repair SUSE php5 -a
Next Topic: Learn Chinese (Mandarin) faster by using flashcards with pictures
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 08:40:29 GMT 2024

Total time taken to generate the page: 0.02810 seconds