include interview questions

Top 15 include interview questions

25181 Jobs openings for include

How to include() all PHP files from a directory?

Very quick n00b question, in PHP can I include a directory of scripts.

i.e. Instead of:


is there something like:


Couldn't seem to find a good way of including a collection of about 10 sub-classes for a particular class.

Source: (StackOverflow)

What is the difference between #include and #include "filename"?

In the C and C++ programming languages, what is the difference between using angle brackets and using quotes in an include statement, as follows?

  1. #include <filename>
  2. #include "filename"

Source: (StackOverflow)

Include javascript file in chrome console

is there a simpler (native perhaps?) way to include a external script file in the google chrome browsers? Currently I'm doing it like this:

document.head.innerHTML+="<script src='http://domain.com/fil.js'></script>";

Source: (StackOverflow)

Difference between "include" and "require" in php

Is there any difference between them? Is using them a matter of preference? Does using one over the other produce any advantages? Which is better for security?

Source: (StackOverflow)

"#include" a text file in a C program as a char[]

Is there a way to include an entire text file as a string in a C program at compile-time?

something like:

  • file.txt:

    This is
    a little
    text file
  • main.c:

    #include <stdio.h>
    int main(void) {
       #blackmagicinclude("file.txt", content)
       equiv: char[] content = "This is\na little\ntext file";
       printf("%s", content);

obtaining a little program that prints on stdout "This is a little text file"

At the moment I used an hackish python script, but it's butt-ugly and limited to only one variable name, can you tell me another way to do it?

Source: (StackOverflow)

What is the difference between #import and #include in Objective-C?

What are the differences between #import and #include in Objective-C and are there times where you should use one over the other? Is one deprecated?

I was reading the following tutorial: http://www.otierney.net/objective-c.html#preamble and its paragraph about #import and #include seems to contradict itself or at least is unclear.

Source: (StackOverflow)

Are PHP include paths relative to the file or the calling code?

I'm having trouble understanding the ruleset regarding PHP relative include paths. If I run file A.PHP- and file A.PHP includes file B.PHP which includes file C.PHP, should the relative path to C.PHP be in relation to the location of B.PHP, or to the location of A.PHP? That is, does it matter which file the include is called from, or only what the current working directory is- and what determines the current working directory?

Source: (StackOverflow)

How should I detect unnecessary #include files in a large C++ project?

I am working on a large C++ project in Visual Studio 2008, and there are a lot of files with unnecessary #include directives. Sometimes the #includes are just artifacts and everything will compile fine with them removed, and in other cases classes could be forward declared and the #include could be moved to the .cpp file. Are there any good tools for detecting both of these cases?

Source: (StackOverflow)

Displaying the #include hierarchy for a C++ file in Visual Studio

Problem: I have a large Visual C++ project that I'm trying to migrate to Visual Studio 2010. It's a huge mix of stuff from various sources and of various ages. I'm getting problems because something is including both winsock.h and winsock2.h.

Question: What tools and techniques are there for displaying the #include hierarchy for a Visual Studio C++ source file?

I know about cl /P for getting the preprocessor output, but that doesn't clearly show which file includes which other files (and in this case the /P output is 376,932 lines long 8-)

In a perfect world I'd like a hierarchical display of which files include which other files, along with line numbers so I can jump into the sources:


Source: (StackOverflow)

Dynamically load a JavaScript file

How can you reliably and dynamically load a JavaScript file? This will can be used to implement a module or component that when 'initialized' the component will dynamically load all needed JavaScript library scripts on demand.

The client that uses the component isn't required to load all the library script files (and manually insert <script> tags into their web page) that implement this component - just the 'main' component script file.

How do mainstream JavaScript libraries accomplish this (Prototype, jQuery, etc)? Do these tools merge multiple JavaScript files into a single redistributable 'build' version of a script file? Or do they do any dynamic loading of ancillary 'library' scripts?

An addition to this question: is there a way to handle the event after a dynamically included JavaScript file is loaded? Prototype has document.observe for document-wide events. Example:

document.observe("dom:loaded", function() {
  // initially hide all containers for tab content

What are the available events for a script element?

Source: (StackOverflow)

What's the difference between including files with JSP include directive, JSP include action and using JSP Tag Files?

It seems that there are two methods for templating with JSP. Including files with one of these statements

<%@ include file="foo.html" %>
<jsp:include page="foo.html" />

or using JSP tag files

// Save this as mytag.tag
<%@ tag description="Description" pageEncoding="UTF-8"%>

And in another JSP page call it with

<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>

    <h1>Hello World</h1>

So which method should I use? Is one now considered deprecated or are they both valid and cover different use cases?


Isn't using this tag file the same as using an include?

// Save this as product.tag
<%@ tag description="Product templage" pageEncoding="UTF-8"%>
<%@ tag import="com.myapp.Product" %>
<%@ attribute name="product" required="true" type="com.myapp.Product"%>

Product name: ${product.name} <br/>
Quantity: ${product.quantity} <br/>

And call it on another JSP with

<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>

    <c:forEach items="${cart.products}" var="product">
        <t:product product="${product}"/>

That seems to me to be the very same as using an include and passing parameters to it. So are Tag Files the same as includes?

Source: (StackOverflow)

What is the difference between include and extend in Ruby?

Just getting my head around Ruby metaprogramming... the mixin/modules always manage to confuse me.

  • include : mixes in specified module methods as instance methods in the target class
  • extend : mixes in specified module methods as class methods in the target class

So is the major difference just this or is a bigger dragon lurking? e.g.

module ReusableModule
  def module_method
    puts "Module Method: Hi there!"

class ClassThatIncludes
  include ReusableModule
class ClassThatExtends
  extend ReusableModule

puts "Include"
ClassThatIncludes.new.module_method       # "Module Method: Hi there!"
puts "Extend"
ClassThatExtends.module_method            # "Module Method: Hi there!"

Source: (StackOverflow)

How to add a default include path for gcc in linux?

I'd like gcc to include files from $HOME/include in addition to the usual include directories, but there doesn't seem to be an analogue to $LD_LIBRARY_PATH. I know I can just add the include directory at command line when compiling (or in the makefile), but I'd really like a universal approach here, as in the library case.

Source: (StackOverflow)

AngularJS ng-include

I'm trying to include an html snippet inside of an ng-repeat, but I can't get the include to work. It seems the current syntax of ng-include is different than what it was previously: I see many examples using <div ng-include src="path/file.html"></div> but in the official docs, it says to use <div ng-include="path/file.html"></div> but then down the page it is shown as <div ng-include src="path/file.html"></div>.

Regardles, I tried

<div ng-include="views/sidepanel.html"></div>

<div ng-include src="views/sidepanel.html"></div>

<ng-include src="views/sidepanel.html"></ng-include>


<ng:include src="views/sidepanel.html"></ng:include>

My snippet is not very much code, but it's got a lot going on; I read in SO#12361680 that that could cause a problem, so I replaced the content of sidepanel.html with just the word foo, and still nothing.

I also tried declaring the template directly in the page like this:

<script type="text/ng-template" id="tmpl">

And running thru all the variations of ng-include referencing the script's id, and still nothin'.

My page had a lot more in it, but now I've stripped it down to just this:

<!-- index.html -->
<!-- angular includes -->
<body ng-view="views/main.html"> <!-- view is actually set in the router -->
    <!-- views/main.html -->
    <article id="sidepanel">
        <section class="panel"> <!-- will have ng-repeat="panel in panels" -->
            <div ng-include src="views/sidepanel.html"></div>
<!-- index.html -->

The header renders, but then my template doesn't. I get no errors in console or from Node, and if I click the link in src="views/sidepanel.html" in dev tools, it takes me to my template (and displays foo).

Source: (StackOverflow)

Include a JavaScript file in another JavaScript file?

Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another JavaScript file?

Source: (StackOverflow)