|
First of all I try and avoid such situations.
When I can't, require_once("../includes/somefile.php"); works for me. But then I'm not sure what would happen if somefile.php would contain another include or require.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
If I make web site by ASP.net , is it give me the flexibly to make forums and Chat ,Profiles and so on
or PHP is the best?
|
|
|
|
|
m_7tem wrote: PHP is the best?
No, not in my books.
PHP may be the most popular approach, ASP.NET would be the professional approach.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
ASP.NET is better than PHP in my opinion...
|
|
|
|
|
While I would prefer ASP.Net, PHP has the advantage of being able to be hosted on Linux servers. This keeps running costs much lower than ASP.Net servers. Functionally they are pretty much the same, PHP has some funny syntax. ASP.Net has the advantage of being able to use C# as code behind, which would integrate better with desktop applications and WCF(web) services. The choice is ultimately just an arbitrary one, dependant on the developer.
|
|
|
|
|
Having recently moved a site from ASP to PHP I can tell you that ASP was 10x easier for me (but most of my exp until recently in programming has been VB, C#). I was able to get things working a lot faster in ASP and how I wanted them to. Off hand I can't really think of anything I have done in PHP that I thought, "God I'm sure glad I'm using PHP to do this, as it's so much easier".
The only up side is the use of a Linux server for PHP. I'm sure there are other pros and cons, but I work on a web site about 3 hours a month for a intranet site here at work and now just use PHP as I'm forced to (admin won't run IIS).
|
|
|
|
|
|
Hello all,
Here a novice trying to concatenate two strings without luck...
Note: The Document root is "www".
$PATH = $_SERVER['DOCUMENT_ROOT'].'/'; This works wonderfully as I can see "www/".
echo $PATH.'FILE.php'; This should show something like: "www/FILE.php"; but it shows "wwwFILE.php".
Why is this happening?
Any idea on what I'm doing that is not correct?
Thank you in advance.
|
|
|
|
|
|
First of all thank you for answering.
I know that I can put the / just before the file name.
The idea was to avoid that: there are thousands of places with the file name but only a few with the path.
I'd like to know why do this happens. I've not seen this behavior documented anywhere.
Thanks again.
|
|
|
|
|
Have you included ALL your code?
This seems impossible if there is no other code between the two lines.
|
|
|
|
|
Why do you ask if I've included ALL the code? I've included some files in order not to repeat code. There are plenty of situations in which I'm using this.
Do I'm missing something?
Here we go...
I know it seems incredible but it is what it happens...
I'm doing something like:
$path = DOC_ROOT.'/';
echo $path; Here it works well.
but if I'm doing something like:
$path = DOC_ROOT.'/';
$path2 = $path.'folderX'
$path3 = $path.'folderY'
include ($path.file1.php);
include ($path2.file9.php);
here it fails in each include and if I'm trying to get echoed the result it also fails.
As I'm using the paths to include code, I've misunderstood at the beginning... my fault...
[www.tamelectromecanica.com] Robots, CNC and PLC machines for grinding and polishing.
modified on Saturday, March 19, 2011 9:19 AM
|
|
|
|
|
don't you mean
include ($path.'file1.php');
include ($path2.'file9.php');
|
|
|
|
|
Yes, I'm at home now without access to the code (using pseudocode here).
|
|
|
|
|
another suggestion: if you know or can calculate your folder depth (currently requested script's distance from the web root) try this:
$sDepth='../../';
require_once($sDepth.'file1.php');
|
|
|
|
|
Your code works fine for me (XAMPP 1.6.6a; PHP 5.2.5).
Look again Monday!
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
<?php
$path_root = $_SERVER['DOCUMENT_ROOT'].'/';
echo $path_root;
include($path_root.'aaa.php');
include($path_root.'bbb.php');
?>
* Error: : "Warning: include(C:/Program Files/EasyPHP-5.3.5.0/wwwbbb.php) [function.include]: failed to open stream: No such file or directory in C:\Program Files\EasyPHP-5.3.5.0\www\index.php on line 9
It seems to me that, for any unknown reason the last '/' is getting removed automatically after using it inside an include clause.
|
|
|
|
|
Three comments:
1.
that looks like a bug then, in your PHP system.
2.
why do you feel a need to specify an explicit path in an include? I never do that, I use relative paths. Wouldn't
include('aaa.php');
include('bbb.php');
work well?
3.
please try again with a backslash in $path_root.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Luc Pattyn wrote: that looks like a bug then, in your PHP system
It had no sense to me... Strange behavior.
Luc Pattyn wrote: why do you feel a need to specify an explicit path in an include?
Probably this is again a bug then... I've tried to use relative paths like '../aaa.php' and so on, but the problem here is that I'm using some files from different locations and those files seem to inherit (somehow) the original path... then the relative paths change depending on the file that is including the file that includes another file... Using the doc_root helps me avoiding this problem...
Luc Pattyn wrote: please try again with a backslash in $path_root.
Done it already... it don't wants to work...
Thank you for your answer!
|
|
|
|
|
you're welcome.
FYI: I typically use:
require_once("includes/somename.php");
i.e. my pages are at the top level of the web site, my dependencies one level down. Never had a problem with it.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
$path_root is a global variable, so maybe something in the 'aaa.php' include (or another file included by that) is modifying it.
|
|
|
|
|
Nice suggestion, I tried this the first thing... searched for all the $path_root variables in the web site in order to find any inconsistence...
The only thing it can happen here is that the include clause is removing the last / in the file path.
I works once, it never works again.
|
|
|
|
|
PHP has two ways for specifying strings.
single quotes ''
double quotes ""
$car = 'Holden';
$sq = 'My car is a $car'; //My car is a $car
$dq = "My car is a $car"; //My car is a Holden
With double quotes the variable is inserted.
If you are using an array or want to seperate a variable in double quotes use braces.
$array['tv_show'] = 'American Idol';
$br = "{$array['tv_show']} is terrible but {$car}'s are awesome";
for the example above use "{$_SERVER['DOCUMENT_ROOT']}/FILE.php";
It may be that you are using windows and the interpreter could be swapping a '/' for '\'.
|
|
|
|
|
Hi,
just wondering if we can create a library(dll type) in php netbeans like we can in .NET.
it's just that i have set of data class and business logic classes and i want to keep them in a seperate library and include that in different projects.
Other question is if it's good way to have library in php or is it better to include each class as and when required ??
Thanks
|
|
|
|
|