Page 1 of 1
PHP Writing Javascript Code
Posted: Mon Jun 26, 2006 1:17 pm
by tecktalkcm0391
Can you put something like:
Code: Select all
<script scr="javascript.php?user=me"></script>
and have the PHP code just display the codes like this:
Code: Select all
<?php
// Javascript.php
print('
function createjsDOMenu() {
cursorMenu1 = new jsDOMenu(150);
with (cursorMenu1) {
addMenuItem(new menuItem("Dynamic Drive", "", "http://www.dynamicdrive.com"));
addMenuItem(new menuItem("-"));
addMenuItem(new menuItem("JavaScript Kit", "", "http://www.javascriptkit.com"));
addMenuItem(new menuItem("Coding Forums", "", "http://www.codingforums.com"));
addMenuItem(new menuItem("FreewareJava", "", "http://www.freewarejava.com"));
addMenuItem(new menuItem("Search Engines", "se", ""));
}');
?>
Posted: Mon Jun 26, 2006 1:26 pm
by Robert Plank
Yes that will work, why waste the time asking if you can try it out first.
Posted: Mon Jun 26, 2006 1:28 pm
by Benjamin
Yes you can, however for chunks of code like that I prefer to drop out of PHP.
Robert Plank wrote:Yes that will work, why waste the time asking if you can try it out first.
Be nice.
Posted: Mon Jun 26, 2006 1:50 pm
by Roja
astions wrote:Robert Plank wrote:Yes that will work, why waste the time asking if you can try it out first.
Be nice.
It wasn't an unreasonable request, nor a rude way to request it, in my opinion.
However, perhaps there was a reason he didn't try it first? (I'm playing devils advocate here)
Posted: Mon Jun 26, 2006 1:54 pm
by RobertGonzalez
Robert Plank wrote:Yes that will work, why waste the time asking if you can try it out first.
Some folks just want the comfort of having someone else try a potentially dangerous solution out before killing
their own system

.
Hey, I have been guilty of this on more than one ocassion. But Feyd usually knows what would have happened and expectedly gives me some insight into the future of what could have been my disastrous stupidity.
Posted: Mon Jun 26, 2006 2:00 pm
by Benjamin
Roja wrote:It wasn't an unreasonable request, nor a rude way to request it, in my opinion.
When I worked at a bank, they said, "It's not what you do, it's the way others perceive what you are doing", referring to any actions that seem to be "shady". I think this concept would also apply in the forum. It's not what you say, so much as how others perceive what you are saying. My first reaction to that post was, "Wow that's a little bit harsh".
Posted: Mon Jun 26, 2006 2:07 pm
by Roja
Everah wrote:Robert Plank wrote:Yes that will work, why waste the time asking if you can try it out first.
Some folks just want the comfort of having someone else try a potentially dangerous solution out before killing
their own system

.
So people can write bad code, let others run it, and let them risk it "killing their system" ?
Thats all kinds of a bad idea, ignoring that php code doesn't really kill a system usually.
Better questions come when you test things yourself first. Lets encourage that behavior.
Posted: Mon Jun 26, 2006 2:21 pm
by Benjamin
<offtopic>
Can someone please test this for me..
Code: Select all
while (1 < 2) {
$filename = rand(0,9999999);
touch($filename);
}
// WARNING, DO NOT RUN THIS CODE!!!
</offtopic>
Edit: I ran this code and it created 94,263 files in 600 seconds.
Posted: Mon Jun 26, 2006 8:03 pm
by RobertGonzalez
Roja wrote:Everah wrote:Robert Plank wrote:Yes that will work, why waste the time asking if you can try it out first.
Some folks just want the comfort of having someone else try a potentially dangerous solution out before killing
their own system

.
So people can write bad code, let others run it, and let them risk it "killing their system" ?
Thats all kinds of a bad idea, ignoring that php code doesn't really kill a system usually.
Better questions come when you test things yourself first. Lets encourage that behavior.
I totally agree with you. Its just that I can almost 'hear it in their voice' when they post those types of questions. They are either too lazy to try it or are too scared. Those of us that know better

know not evaluate code that will cause issues.
I guess what I am saying here is that I do not condone what these folks are doing. I am just trying to sort of explain what I think they do it. I will be the second (you being the first) to encourage proper testing of ones code before posting errors or questions about it.
Posted: Mon Jun 26, 2006 8:04 pm
by RobertGonzalez
astions wrote:<offtopic>
Can someone please test this for me..
Code: Select all
while (1 < 2) {
$filename = rand(0,9999999);
touch($filename);
}
// WARNING, DO NOT RUN THIS CODE!!!
</offtopic>
Edit: I ran this code and it created 94,263 files in 600 seconds.
Insanely funny

.