Reply to Re: A Simple PHP Question, I'm sure

Your name:

Reply:


Posted by Lee David on 06/08/05 01:28

I'm sure the gurus will chime in with where I'm wrong, but you seem to be
mixing javascript with PHP where it isn't mixable.

PHP doesn't use the document object at all like javascript does. You might
replace what you have with this:

> <script language="JavaScript">
> var greeting = <?php echo $SomePHPVariable?>
>
> document.write("I am saying " + greeting)
>
> </script>

Remember, PHP happens before it is sent to the browser and javascript
happens after it is sent to the browser. If you did the whole think in PHP
it would look like this:
<?php
$greeting = "some value";
echo "I am saying " . $greeting; // the "." is the concatenation
operator.
?>

"Kees Boer" <keesboer@integrity-computing.net> wrote in message
news:wTope.49079$gc6.10374@okepread04...
> Hi, I had a question, which I'm sure is fairly simple, but for some
> reason, I can't seem to be able to find the answer on line.
>
> I'm trying to create webpages that are all very similar, just with some
> variable content. I can do it in Java script, but then Internet Explorer
> 6.0 will block it for most side, so I tried to do it in PHP, but I'm
> getting errors.
>
> This is the code in JavaScript, which works:
>
> <html>
> <head>
> <title>Untitled Document</title>
>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <body bgcolor="#FFFFFF" text="#000000">
>
> <script language="JavaScript">
> var greeting = "Hello There!!!"
>
> document.write("I am saying " + greeting)
>
> </script>
>
> </body>
> </html>
>
> Now I'm trying to run it in PHP.
>
> This is what I came up with but it has errors:
>
> <html>
> <head>
> <title>Untitled Document</title>
>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> <body bgcolor="#FFFFFF" text="#000000">
>
> <script language="php">
> var greeting = "Hello There!!!"
>
> document.write("I am saying " + greeting)
>
> echo greeting
>
> </script>
>
>
> </body>
> </html>
>
> I've been searching on line for some tutorial or something to teach me the
> syntax, but I can't seem to find it. What did I do wrong?
>
> Thank you!
>
> Kees
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация