require

Why does Ruby 1.9.2 remove "." from LOAD_PATH, and what's the alternative?

The latest changesets to Ruby 1.9.2 no longer make the current directory . part of your LOAD_PATH. I have a non-trivial number of Rakefiles that assume that . is part of the LOAD_PATH, so this broke them. Was there a particular justification for doing this? As for a fix, adding $: << "." everywhere works, but seems incredibly hacky and ...

How to I create include files in Lua language.

I want to create a header file in lua (header.lua), then do the "require" function to load it. How do I do require a file that I have created? Thanks ...

RAILS_ROOT require?

I'm trying to access the RAILS_ROOT constant in a file residing in the /lib directory, but I'm not able to (uninitialized constant error). Is there something that I need to require to be able to do this? Sorry if this is a dumb question.. ...

Include, require & require_once

Hi there. Today I've tried to include file that returns object. I always use require_once, however now I've noticed weird behavior of it. File main.php $lang = false; $lang->name = "eng"; $lang->author = "Misiur"; $lang->text = "Text is test"; $lang->undefined = "Undefined"; return $lang; File index.php $lang = include('langs/eng/m...

PHP - What's faster, memcache or require?

I'm trying to load in predefined email messages to send out -- my question is, should I memcache all the email messages rather than just including the file that contains the variables with the email messages, and only call it once a day or something? ...

What is the difference between these PHP include statements?

include("somefile.php"); include_once("somefile.php"); require("somefile.php"); require_once("somefile.php"); What is the difference between these? ...

How to link LuaSQL in a C++ application?

My script runs fine when I execute it from outside the application (terminal), but when its called from inside the C++ application it shuts down in the require("luasql.mysql") call. Can anyone help? ...

PHP: Require path does not work for cron job?

I have a cron job that needs to include this file: require '../includes/common.php'; however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron job runs the following file (on the live server): /home/username123/public_html/cron/mycronjob.php and here's the error: Fatal error: re...

I have a require("config.php") with arrays, but still get Undefined variable error

Hi. I hava a function that looks something like this: require("config.php"); function displayGta() { (... lots of code...) $car = $car_park[3]; } and a config.php that look something like this: <?php $car_park = array ("Mercedes 540 K.", "Chevrolet Coupe.", "Chrysler Imperial.", "Ford Model T.", "Hudson Super.", "Packard ...

functions in require("x.php") works in some of the code, but cannot be called in the next?

Hi. I have this code ` require("db_connect.php"); function xx() { $conn = db_connect(); //here it works (...) date_default_timezone_set('Europe/Paris'); if(time() <= $x[0]){ (...) }else { (...) for...

Rails 3: how to load files in /lib?

I'm new to rails and making some sort of noob mistake: I frequently need to count the number of lines in a file, so I'm trying to monkey patch class File like this: class File def self.line_count( filename ) %x{wc -l #{filename}}.split.first.to_i end end I saved this to /lib/file_util.rb. I thought that this was supposed to...

does google-app-engine has "required_admin" method..

@required_admin def get(self): i want to use this method to make user must be admin. thanks ...

Require upload of a file in HTML/PHP form

Hi, I'm trying to require a file upload in a form, but cannot get it to work. Any ideas? I'd rather echo the php error on the page vs. a javascript popup. Thanks for taking a look: <?php // initialize $file1 $file1 = $_POST['file1']; // check upload of $file1 if ($file1 == '' ) { $error = "Please upload an image"; } ?> ...

How do to multiple imports in Python ?

In Ruby, instead of repeating the "require" (the "import" in Python) word lots of times, I do %w{lib1 lib2 lib3 lib4 lib5}.each { |x| require x } So it iterates over the set of "libs" and "require" (import) each one of them. Now I'm writing a Python script and I would like to do something like that. Is there a way to, or do I need to ...

PHP - retrieve name of script that included or required it

How do you retrieve the name of the script that included or required it? Example: script login.php has a require_once('validate.php') ... validate.php is also called by a number of other scripts. Other than manually setting a flag, is there a way to have validate.php know which script is including/requiring it? ...

Correct link rel CSS stylesheet not being implemented for a menu

I have menu.php, and in the <head> section of menu.php, I have menu.css as a link rel tag of course, both of which work perfectly fine. Since menu.php is a 'menu', I've required it on pages that need a 'menu' in order to navigate around the website. However, whenever I require menu.php on a page that has its own CSS stylesheet, menu.php...

How can I force require a file in the console? The 'reload!' command just dosen't work!

I use rails-3.0.0.beta3 and ruby-1.9.2-preview3. I have defined some new methods in the application_controller.rb, and need to test them in the console. If I changed some codes in the application_controller.rb. I have to restart the console. I have tried to use 'reload!' command, just dosen't work. And then I use "require 'applicati...

interpreting php as plain text when using php function require

Hello I have main site to which i put code using require function, but when i add php functions into it, they appear as plain text. The php code is rather long so i won't paste it here. Could anyone help me with that? Thanks ok i am adding some code: require part with only one function: <?php $content=<<<EOF echo 'hello'; EOF; requ...

PHP include file extensions?

For required/included files in PHP, is it better to use .inc extensions vs .inc.php vs .php extensions? ...

PHP - filename calls function on different script, get filename from script containing function

fileA.php: requires function.inc.php and uses x() from that include file fileB.php: requires fileA.php User invokes fileB.php to get fileA.php function.inc.php: function x() - returns filename that invoked it What is the PHP server variable or whatever that gets the name of fileA.php from within function.inc.php? Usecase - function ...