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 7761821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:14:06+00:00 2026-06-01T14:14:06+00:00

I want to include external js file in my php script. I am following

  • 0

I want to include external js file in my php script. I am following zend framework.Right now I am adding js file in controller’s init function like this.

public function init() {
    $this->doUserAuthorisation();
    parent::init();
    $this->view->headScript()->appendFile($this->view->baseUrl().'/js/front_cal/jquery-1.3.2.min.js');  
    $this->view->headLink()->setStylesheet($this->view->baseUrl().'/styles/front_cal/calendar.css');
}

problem what i am facing is, js file doesnot include.Is this the right way to include js file?

  • 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-06-01T14:14:08+00:00Added an answer on June 1, 2026 at 2:14 pm

    JavaScript (and images, CSS, flash movies, etc) belong to the view layer so configure them there.

    For globally included files, add them to your layout, eg

    <!-- layout.phtml -->
    <head>
        <?php echo $this->headScript()->prependFile(
            $this->baseUrl('path/to/file.js')) ?>
        <?php echo $this->headLink()->prependStylesheet(
            $this->baseUrl('path/to/file.css')) ?>
    
    <!-- snip -->
    
        <?php echo $this->inlineScript()->prependFile(
            'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js') ?>
    </body>
    

    Your view scripts can then add assets to the helpers which are echoed out in the layout. As the layout uses the prepend*() methods, the global files will be displayed first, eg

    <?php // views/scripts/index/index.phtml
    $this->inlineScript()->appendFile($this->baseUrl('path/to/script.js'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to include the last 2 files in my php file based on
I want to include a header file only if a certain function body is
I have a batch file and I want to include an external file containing
I want to include an external file, and then get all the content, remove
I want to include an external file as a class body, something like this:
I want to call function in PHP i use require_once for this .... now
We have an external .js file that we want to include in a number
I want to include some dynamic part in the filename of the msi file
I'm creating a PHP web application framework (MVC). I'd rather not use external libraries
Here's what I need to do -- either : include an external file in

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.