Include Problem ?
10 Message(s) by 4 Author(s) originally posted in php programming
| From: Xav |
Date: Thursday, October 25, 2007
|
Why does thisn't work ?
$fileDir = '../folder2/';
$content is an
array of php files, file1.php file2.php file3.php
etc...
$c = count($content);
for( $x=0; $x<$c; $x++ ){
include ( $fileDir.$content[$x] );
}
any ideas'd be appreciated,
thanks.
Xav
| From: Xav |
Date: Friday, October 26, 2007
|
this seems to work,
...
for( $x=0; $x<$c; $x++ ){
include( $fileDir.'file'.($x+1).'.php' );
}
...
I do not understand why the other won't !
???
Xav
| From: Thomas Hamacher |
Date: Friday, October 26, 2007
|
Xav schrieb:
Why does thisn't work ?
$fileDir = '../folder2/';
$content is an array of php files, file1.php file2.php file3.php
etc...
$c = count($content);
for( $x=0; $x<$c; $x++ ){
include( $fileDir.$content[$x] );
}
This should work if $content really contains what you expect.
var_dump($content);
| From: Xav |
Date: Friday, October 26, 2007
|
I did the
<pre>...
</pre> thing...
it shows;
[0] => file1.php
[1] => file2.php
etc...
as expected!
I think I found a Bug!
this really does not work, I was thinking my
logic was at fault,
could it be a php.ini setting problem ? I do not know of any settings
that govern logic.
thanks for response,
Xav
| From: Rik Wasmus |
Date: Friday, October 26, 2007
|
wrote in message:
I did the <pre>...</pre> thing...
it shows;
[0] =3D> file1.php
[1] =3D> file2.php
etc...
as expected!
I think I found a Bug!
Not very likely.
Do this:
$c =3D count($content);
for( $x=3D0; $x
<$c; $x++ ){
echo "|{$fileDir}{$content[$x]}|\n";
}
The pipes are there to discover whitespace, a normal space'd account=
=
for the difference. Normally I'd be against using <pre>, just look at th=
e =
source. And please enable error_reporting & display_errors while =
developing, and tell us why PHP sais the include fails.
-- =
Rik Wasmus
| From: Captain Paralytic |
Date: Friday, October 26, 2007
|
wrote in message:
wrote in message:
> I did the <pre>...</pre> thing...
> it shows;
> [0] => file1.php
> [1] => file2.php
> etc...
> as expected!
> I think I found a Bug!
Not very likely.
Do this:
$c = count($content);
for( $x=0; $x<$c; $x++ ){
echo "|{$fileDir}{$content[$x]}|\n";
}
The pipes are there to discover whitespace, a normal space'd account
for the difference. Normally I'd be against using <pre>, just look at the
source. And please enable error_reporting & display_errors while
developing, and tell us why PHP sais the include fails.
--
Rik Wasmus
Surely {$content[$x]} won't work. PHP does only one substitution so
{$content[1]} will work but {$content[$x]} does not (at least in my
experience).
| From: Rik Wasmus |
Date: Friday, October 26, 2007
|
On Fri, 26 Oct 2007 12:47:44 +0200, Captain Paralytic =
wrote in message:
wrote in message:
wrote in message:
> I did the
<pre>...
</pre> thing...
> it shows;
> [0] =3D> file1.php
> [1] =3D> file2.php
> etc...
> as expected!
> I think I found a Bug!
Not very likely.
Do this:
$c =3D count($content);
for( $x=3D0; $x
<$c; $x++ ){
echo "|{$fileDir}{$content[$x]}|\n";
}
The pipes are there to discover whitespace, a normal space'd acco=
unt
for the difference. Normally I'd be against using <pre>, just look at=
=
the
source. And please enable error_reporting & display_errors while
developing, and tell us why PHP sais the include fails.
Surely {$content[$x]} won't work. PHP does only one substitution so
{$content[1]} will work but {$content[$x]} does not (at least in my
experience).
The code:
<?php
echo phpversion();
$foo =3D array(3 =3D> 'bar');
$x =3D 3;
echo "{$foo[$x]}";
?>
Output:
5.2.4bar
The magic is in the braces.
-- =
Rik Wasmus
| From: Captain Paralytic |
Date: Friday, October 26, 2007
|
wrote in message:
On Fri, 26 Oct 2007 12:47:44 +0200, Captain Paralytic
wrote in message:
wrote in message:
wrote in message:
> I did the <pre>...</pre> thing...
> it shows;
> [0] => file1.php
> [1] => file2.php
> etc...
> as expected!
> I think I found a Bug!
Not very likely.
Do this:
$c = count($content);
for( $x=0; $x<$c; $x++ ){
echo "|{$fileDir}{$content[$x]}|\n";
}
The pipes are there to discover whitespace, a normal space'd account
for the difference. Normally I'd be against using <pre>, just look at
the
source. And please enable error_reporting & display_errors while
developing, and tell us why PHP sais the include fails.
> Surely {$content[$x]} won't work. PHP does only one substitution so
> {$content[1]} will work but {$content[$x]} does not (at least in my
> experience).
The code:
<?php
echo phpversion();
$foo = array(3 => 'bar');
$x = 3;
echo "{$foo[$x]}";
?>
Output:
5.2.4bar
The magic is in the braces.
--
Rik Wasmus- Hide quoted text -
- Show quoted text -
So'd
echo "$foo[$x]";
not work then?
| From: Captain Paralytic |
Date: Friday, October 26, 2007
|
wrote in message:
wrote in message:
> On Fri, 26 Oct 2007 12:47:44 +0200, Captain Paralytic
wrote in message:
wrote in message:
wrote in message:
> > I did the <pre>...</pre> thing...
> > it shows;
> > [0] => file1.php
> > [1] => file2.php
> > etc...
> > as expected!
> > I think I found a Bug!
> Not very likely.
> Do this:
> $c = count($content);
> for( $x=0; $x<$c; $x++ ){
> echo "|{$fileDir}{$content[$x]}|\n";
> }
> The pipes are there to discover whitespace, a normal space'd account
> for the difference. Normally I'd be against using <pre>, just look at
> the
> source. And please enable error_reporting & display_errors while
> developing, and tell us why PHP sais the include fails.
> > Surely {$content[$x]} won't work. PHP does only one substitution so
> > {$content[1]} will work but {$content[$x]} does not (at least in my
> > experience).
> The code:
> <?php
> echo phpversion();
> $foo = array(3 => 'bar');
> $x = 3;
> echo "{$foo[$x]}";
> ?>
> Output:
> 5.2.4bar
> The magic is in the braces.
> --
> Rik Wasmus- Hide quoted text -
> - Show quoted text -
So'd
echo "$foo[$x]";
not work then?- Hide quoted text -
- Show quoted text -
Hmmm, interesting. Works with or without the braces. Now I'm sure I
had a situation like this where it did not work...
| From: Rik Wasmus |
Date: Friday, October 26, 2007
|
On Fri, 26 Oct 2007 13:04:58 +0200, Captain Paralytic =
wrote in message:
wrote in message:
On Fri, 26 Oct 2007 12:47:44 +0200, Captain Paralytic
> Surely {$content[$x]} won't work. PHP does only one substitution so=
> {$content[1]} will work but {$content[$x]} does not (at least in my
> experience).
The code:
<?php
echo phpversion();
$foo =3D array(3 =3D> 'bar');
$x =3D 3;
echo "{$foo[$x]}";
?>
Output:
5.2.4bar
The magic is in the braces.
So'd
echo "$foo[$x]";
not work then?
That's a whole other issue, and in this case it'd work. See for a =
detailed explanation =
http://nl2.php.net/manual/en/language.types.string.php#language.types.st=
ring.parsing
Would we change it to this:
<?php
echo phpversion();
$foo =3D array(array(3 =3D> 'bar'));
$x =3D 3;
//works, outputs 'bar'
echo "{$foo[0][$x]}";
//does not work, outputs 'Array[3]'
echo "$foo[0][$x]"
?>
... which is why it's a good thing to pick up the habit to use curly =
braces when using something other then a direct
scalar in a string.
-- =
Rik Wasmus
Next Message: anyone know this error msg?
Blogs related to Include Problem ?
Find :all include problems in Programming Rails : Models and Database
The
include array is actually autogenerated by following the different from a much simpler code.... but I thought that adding the
include code would make the post a bit too long... (it's already going to scare away people by being too
...
PHP include Problem
_education.
php) just above the parent Connect link at the bottom left. So what i did is this, I will give you a copy of the code, with the
includes showing, since i can't put a lot of charactors on here I cut off the body section of the
...
tranzlation in php
Note:
PHP also provides an interface to the GNU gettext gettext http://
php.net/gettext. library. This is a generic library created to handle internationalization/localization
problems. Using it requires building the support for it into
...
Strange include template issue
The
problem is, the client only used a 3G connection to connect to the internet. At this point, some of you might be shaking your head, saying that well if it works on a DSL connection, it shouldn't matter what other connection you're
...
Problem with Shipping Module
Warning: main(/content/DesignerPlus/t/h/www.themagicchest.co.uk/web/
includes/languages/english/modules/shipping/old_usps.
php) [function.main]: failed to open stream: No such file or directory in
...
Shipping Moduls problem
Per Unit perweightunit Store Pickup storepickup Table Rate table 1 United Parcel Service ups Fatal error: Cannot redeclare class usps in /content/DesignerPlus/t/h/themagicchest.co.uk/web/
includes/modules/shipping/usps.
php on line 13
...