Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6053505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:02:51+00:00 2026-05-23T08:02:51+00:00

I’m learning all this web programming stuff after years writing .EXE Windows programs so

  • 0

I’m learning all this web programming stuff after years writing .EXE Windows programs so bear with me.
I developed a basic .php and mysql website that works fine.

But I went to add javascript code to my index.php and I don’t think the javascript code is executing.

My index.php has the form:

<?php

   require_once blah blah

   call_my_php_functionBlah();

?>

Then I added this code inside the php blocks of the ‘<\?\php’ and “\?>” as follows:

<script type="text/javascript">
  // some known-good javascript code that displays an image
</script>

Nothing showed up.
So I thought “ah-HAH, I blew it, all I need to do is — move the javascript code outside
of the php block, at the bottom of index.php, and surely I’m good to go.”

And still, Nothing showed up.

I checked the source of my ‘known-good’ javascript code and it said ’embed this javascript code
in your HTML file’ so I thought “wow, I guess I need an index.html or something here.”

So my questions:

1) should my index.php be able to run the javascript block of code?
I’m guessing ‘No because index.php executes on the server and javascript runs on the client machine.’

2) How should I architect this if I want to keep my index.php, whose code works fine and I don’t want to mess with it?

I’m thinking that this is an extremely basic client/server, php and javascript script organization issue that every web programmer knows how to handle, but like I said, I’m new to all this. I read in the archives about .htaccess etc. etc. but I
bet there’s an easier way, and I’m not sure if the stuff I read applies.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:02:52+00:00Added an answer on May 23, 2026 at 8:02 am
    • the file name extension is completely irrelevant
    • PHP executes on the server and doesn’t care at all about any Javascript
    • code inside <?php ?> tags must of course be valid PHP code to be executed by PHP
    • your browser receives whatever the result of your PHP execution is
    • you can use PHP code to output Javascript or simply have Javascript on the same page outside of <?php ?> tags
    • only whatever the browser receives matters, so use View Source
    • look at the browser’s Javascript Console to debug client-side Javascript problems
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have text I am displaying in SIlverlight that is coming from a CMS
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.