php-general Digest 9 Sep 2007 17:53:09 -0000 Issue 5009

Topics (messages 261864 through 261875):

Arabic (Hindi) Numerals
        261864 by: OOzy Pal
        261866 by: Per Jessen

Re: Can't execute PHP script
        261865 by: Børge Holen
        261870 by: brian

Re: Pack function in C#
        261867 by: Per Jessen

Re: Buxa Coding Guidelines
        261868 by: Per Jessen
        261869 by: Per Jessen
        261871 by: Greg Donald
        261872 by: brian
        261873 by: brian

Link problem - newbie question
        261874 by: Suvarna Damodaran
        261875 by: brian

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
I am looking for codes to convert the roman western English characters
to its Arabic (Hindi) entities. For example the letter 5 Arabic
numeral entity is ٥

-- 
OOzy
Ubuntu-Feisty

--- End Message ---
--- Begin Message ---
OOzy Pal wrote:

> I am looking for codes to convert the roman western English characters
> to its Arabic (Hindi) entities. For example the letter 5 Arabic
> numeral entity is ٥
> 

This is not just plain conversion from one characterset to another? (in
which case you could proabbly use iconv()).  


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
On Saturday 08 September 2007 17:21, brian wrote:
> Randy Patterson wrote:
> > Hey,
> >
> > [Note:] This is a different problem from the one I posted earlier today.
> >
> > I can't get my LAMP server setup to run PHP script.
> >
> > As returned by apache2ctl, I am running;
> >
> > Apache/2.2.4 (Debian) PHP/5.2.3-1+b1
> >
> > I point my browser to;
> >
> > http://localhost/apache2-default/test.php
> >
> > The file test.php contains this code;
> >
> > <html><body>
> > <h1>PHP Test</h1>
> > <br />
> > <?php print "Hello World!"; ?>
> > </body></html>
> >
> > The browser outputs only;
> >
> > PHP Test
>
> Check in your httpd.conf that you have all of the following:
>
> LoadModule php5_module        modules/libphp5.so
> AddHandler php5-script        php
> AddType text/html       php
>
> Make sure they're in there and uncommented. And that you restart httpd.

no he should not. this resides within the php5.load file.
He must symlink his files.
Debian does not utilize httpd.conf for any specific reason since apache2, it's 
just there for compability reasons

>
> brian

--- End Message ---
--- Begin Message ---
Børge Holen wrote:
On Saturday 08 September 2007 17:21, brian wrote:

Randy Patterson wrote:

Hey,

[Note:] This is a different problem from the one I posted earlier today.

I can't get my LAMP server setup to run PHP script.

As returned by apache2ctl, I am running;

Apache/2.2.4 (Debian) PHP/5.2.3-1+b1

I point my browser to;

http://localhost/apache2-default/test.php

The file test.php contains this code;

<html><body>
<h1>PHP Test</h1>
<br />
<?php print "Hello World!"; ?>
</body></html>

The browser outputs only;

PHP Test

Check in your httpd.conf that you have all of the following:

LoadModule php5_module  modules/libphp5.so
AddHandler php5-script  php
AddType text/html       php

Make sure they're in there and uncommented. And that you restart httpd.


no he should not. this resides within the php5.load file.
He must symlink his files.
Debian does not utilize httpd.conf for any specific reason since apache2, it's just there for compability reasons


brian



Oh, right--Debian. My bad.

--- End Message ---
--- Begin Message ---
Symbian wrote:

> 
> hello,
> 
> Our PHP dev (who has since left) uses the pack function to turn a
> base64 string into a binary blob (?):
> 
> $blob = pack("H*", $postBase64Data);
> 
> Does anyone know what the above is doing? 

Doesn't the manual tell you:

http://www.php.net/manual/en/function.pack.php


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
magoo wrote:

> In their oppinion stuff like the short PHP init "<?" or inline echo
> "<?= $var ?>" is forbidden.
> Do you people code that strict?


Yep.  If you're using XHTML you have no other option.


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
Greg Donald wrote:

> On Sun, 9 Sep 2007, magoo wrote:
>> Just wanted to see what you think of the strictness of Buxa,
>> according to their PHP guidelines:
>> http://www.buxaprojects.com/en/php_coding_guidelines.htm
>>
>> In their oppinion stuff like the short PHP init "<?" or inline echo
>> "<?= $var ?>" is forbidden.
>> Do you people code that strict?
> 
> I don't put PHP in my HTML.  I use PHP to build my HTML, using heredoc
> syntax while doing so.  My scripts usually only have a single <?php
> opening tag and never require any closing ?> tags.

I use the PHP/HTML mix - seems to make it easier for me to use apache
language-negotiation.  My PHP code is language-neutral, my HTML files
aren't.


/Per Jessen, Zürich

--- End Message ---
--- Begin Message ---
On Sat, 8 Sep 2007, mike wrote:
> although handing off to a templating engine/presentation layer would
> be even better of course.

eval() is my favorite templating engine.


-- 
Greg Donald
Cyberfusion Consulting
http://cyberfusionconsulting.com/

--- End Message ---
--- Begin Message ---
Per Jessen wrote:
magoo wrote:

In their oppinion stuff like the short PHP init "<?" or inline echo
"<?= $var ?>" is forbidden.
Do you people code that strict?

Yep.  If you're using XHTML you have no other option.


If you're parsing XHTML that is choking on any instances of "<%" then you've got a problem with your script. The point of including PHP tags inside of an "XHTML" file is that it isn't really XHTML until PHP has parsed it for its own instructions. Until then, it isn't XHTML yet and shouldn't be treated as such. If you've some need to treat the raw files as XHTML on the server *before* it reaches PHP then you're doing something wrong.


Greg Donald wrote:
>
> I don't put PHP in my HTML.  I use PHP to build my HTML, using heredoc
> syntax while doing so.  My scripts usually only have a single <?php
> opening tag and never require any closing ?> tags.

You make it sound as if you've saved yourself having to type 2 characters. If you're using Zend or a template engine and your scripts do not contain anything other than PHP then you *should not* include the closing tag. It's not really a choice (well, it is, but you run the risk of creating difficult-to-track bugs).

It all depends on the context. For example:

Say i turn an existing HTML file into a PHP script and add some instructions somewhere within the middle of the body. Of course i'm going to have to use a closing tag somewhere before the next bit of HTML markup. But i certainly don't care that my script *requires* that i use that closing tag. I don't think, "Gee, i wish i didn't have to put this closing tag here."


> Code that contains short open tags or instances of <?= is amatuer in
> my opinion.

Amateur? I agree that short open tags should be avoided but i don't see anything wrong with using the <?= ?> construct. When a full-blown templating engine is not available it can be a huge help to break down pages into seperate portions, each containing instructions for the PHP engine to fill in. Got a script that displays a form on one request and something different on another? It's easy to simply include() the necessary HTML part from another file, complete with <?= ?> instances to fill in the stuff you want PHP to gather.

Hence, a poor man's template. I open the file and see an HTML form and can follow it easily. I don't have to wade through a bunch of heredoc blocks in the main script. Instead, the script where i'm doing all the heavy lifting is empty of presentational markup that would only get in the way.

I find it amusing when people go on and on about keeping their PHP instructions out of the markup yet have no qualms about doing precisely the opposite. Six of one ...

It's a matter of determining what is the model and what is the view and how best to create an application structure.

And using echo or heredoc to create HTML usually creates unreadable markup, IMO. That may not matter to some but for those of us who are responsible for ensuring pages validate it certainly helps when your editor of choice (i use jEdit) can highlight the syntax--both PHP and HTML--properly. Markup stuck in a heredoc (or ~shudder~ a thousand echo statements) isn't so easy on the eyes.

In these "templates"i use, aside from filling in spots with <?= $my_var ?> i may also have the odd loop to iterate over a database result. Not so different from XSL, in fact. But i don't have all of the DB queries, checking of credentials, class definitions (yes, i've seen it: classes defined in the same 10,000-line script that the browser requests) inside of that file. It wouldn't be anything remotely similar to a template then.

There's certainly a case to be made for ensuring that scripts follow certain guidelines but to assert that there is *one* proper way for all cases seems a bit off to me. Use what works, makes sense, and is *safe* within *your* workflow.

Just thought i'd add something to get the discussion going beyond, "Me too! That way is teh suxxor." ;-)

brian

--- End Message ---
--- Begin Message ---
Greg Donald wrote:
On Sat, 8 Sep 2007, mike wrote:

although handing off to a templating engine/presentation layer would
be even better of course.


eval() is my favorite templating engine.

You've just made my day. Mind if i put that on a t-shirt?

--- End Message ---
--- Begin Message ---
Hi,

I think I am having an unusual problem - don't know where I am going wrong.
This is the code that I use to display the page once the user is logged in. 
I want to display a Logout link so the user can logout. But, for some 
reason, I am unable to display both the welcome message and the Logout link 
simultaneously unless I insert the line <p><a href = 
"something.htm">hi</a></p> on top and below the welcome line. Without this 
line only Logout (without the link) is displayed. What am I doing wrong?

<?php include 'accesscontrol.php'; ?>
<html>
<head>
  <title> Members-Only Page </title>
  <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1
</head>
<body>
<p><a href = "something.htm">hi</a></p>
<h1>Welcome, <?=$username?>! </h1>
<p><a href = "something.htm">hi</a></p>
<p><a href = "logout.php">Logout</a></p>
</body>
</html>

Thanks,
Su 

--- End Message ---
--- Begin Message ---
Suvarna Damodaran wrote:
Hi,

I think I am having an unusual problem - don't know where I am going wrong.
This is the code that I use to display the page once the user is logged in. I want to display a Logout link so the user can logout. But, for some reason, I am unable to display both the welcome message and the Logout link simultaneously unless I insert the line <p><a href = "something.htm">hi</a></p> on top and below the welcome line. Without this line only Logout (without the link) is displayed. What am I doing wrong?

<?php include 'accesscontrol.php'; ?>
<html>
<head>
  <title> Members-Only Page </title>
  <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1
</head>
<body>
<p><a href = "something.htm">hi</a></p>
<h1>Welcome, <?=$username?>! </h1>
<p><a href = "something.htm">hi</a></p>
<p><a href = "logout.php">Logout</a></p>
</body>
</html>


Your meta tag is not closed (the attribute quote isn't even closed).
<meta http-equiv="Content-Type"
 content="text/html; charset=iso-8859-1" />

Additionally, don't put spaces around the "=" in your tags.

brian

--- End Message ---

Reply via email to