473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Full path for include files (differences between 5.3 and 5.6)

Claus Mygind
571 512MB
In upgrading our system from PHP v 5.3.3 to 5.6.x on a apache 2.4.18 server running on Windows 7, we ran into a problem with include files.

We were using full path for our includes i.e.
Expand|Select|Wrap|Line Numbers
  1. include("c:\webSpace\Library\employee.php")
  2.  
This ran just fine in v5.3.3 But in newer versions 5.6 and 7, file names that started with an "e" were escaped so it was transmitted like this:
Expand|Select|Wrap|Line Numbers
  1. include(c:\webSpace\Librarymployee.php)
Of course there were two solutions:

1. escape the \ like so:
Expand|Select|Wrap|Line Numbers
  1. include("c:\webSpace\Library\\employee.php")
2. Or perhaps the better option add the path to php.ini file like so:
Expand|Select|Wrap|Line Numbers
  1. include_path = ".;C:\webSpace\Library" 
then the include would look like this:
Expand|Select|Wrap|Line Numbers
  1. include("employee.php") 
eliminated the path all together.


My questions are these:
1. What happened between version 5.3.x and 5.6.x?

2. Why are only files starting with the letter "e" affected?
A file like this still worked just fine -
Expand|Select|Wrap|Line Numbers
  1. include("c:\webSpace\Library\payScale.php")
Dec 16 '15 #1

✓ answered by Claus Mygind

I resolved my issue and thought it best not to leave this question hanging in case others are wondering the same.

What you're seeing is a result of the escape sequence \e, which is the ESC character (0x1B (27) in ASCII). This was added in PHP 5.4.4, which explains the difference between versions. This only occurs with that exact character sequence ("\e"), which explains why the other paths work fine.

Also, this only occurs within double-quoted strings, so another solution is to simply use single quotes around your paths.

Just to be clear, you would have similar issues if your paths used any of the escape sequences, such as \n (linefeed) or \t (tab). It's just a consequence of using Windows-style backslash directory separators inside double-quoted strings.

Based on this research, I think it is best to eliminate the need for full path and simply set the include path in the PHP ini file

Expand|Select|Wrap|Line Numbers
  1. include_path = ".;C:\webSpace\Library"
Multiple locations/folders/paths can be added to this path statement. Of course if you have many locations each with many files it may be more efficient to use the full path but use the single quote instead of the double quote to enclose your statement.

1 1188
Claus Mygind
571 512MB
I resolved my issue and thought it best not to leave this question hanging in case others are wondering the same.

What you're seeing is a result of the escape sequence \e, which is the ESC character (0x1B (27) in ASCII). This was added in PHP 5.4.4, which explains the difference between versions. This only occurs with that exact character sequence ("\e"), which explains why the other paths work fine.

Also, this only occurs within double-quoted strings, so another solution is to simply use single quotes around your paths.

Just to be clear, you would have similar issues if your paths used any of the escape sequences, such as \n (linefeed) or \t (tab). It's just a consequence of using Windows-style backslash directory separators inside double-quoted strings.

Based on this research, I think it is best to eliminate the need for full path and simply set the include path in the PHP ini file

Expand|Select|Wrap|Line Numbers
  1. include_path = ".;C:\webSpace\Library"
Multiple locations/folders/paths can be added to this path statement. Of course if you have many locations each with many files it may be more efficient to use the full path but use the single quote instead of the double quote to enclose your statement.
Dec 17 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Don | last post by:
How do I retrieve the full path (C:\.....filename) of a file uploaded to a php script on the server. I think $_FILES will only provide 'name', which is only the filename itself. Thanks, Don ...
7
by: mark | last post by:
I am designing a website at the moment and looking at the difference between relative and absolute url links which is driving me crazy! I would like to use relative paths, but it is proving very...
2
by: Naresh Agarwal | last post by:
Hi How can I view the full path of source files in Visual Studio .Net? thanks, Naresh
2
by: Jiri Brada | last post by:
Hello! I have a Visual Studio .NET application and I have a list of most recently used files under the menu item File. What makes me angry is that only truncated path (e.g....
4
by: Dots | last post by:
I have a class library with a method called getpath(). I want to be able to get the full path of a folder and write some files to the (my_files_dir) folder. A console application will use this...
4
by: pedestrian via DotNetMonster.com | last post by:
I'm using VB 2005. How to get the full path for "Program Files" folder in Windows, ie. either it is C:\Program Files or D:\Program Files or etc.? How about the full path of "Windows" folder?...
2
by: hugh welford | last post by:
Hi Just upgraded to Vista Ultimate, and running IIS7 for offline web development. Suddenly getting the message --------------------------------------------------------- Active Server Pages...
2
by: tvjraman | last post by:
I've spent two days on google trying to find a suitable solution for getting the full path of the running process but in vain. My question is very simple. I want to know the full path of the...
5
ollyb303
by: ollyb303 | last post by:
Hello, I have a small problem that I hope someone can help with. My Access 2000 database uses several tables and is split into BE and FE. In the FE the tables are all linked to the BE but...
4
by: Michel Rouzic | last post by:
I made a program that accepts as parameters an input file name that we'll call file1, and an output file name that we'll call file2, and opens on its own a configuration file called file3. My...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.