Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-09-04 10:23:11

wimmaskerdrie
New Member
Registered: 2007-09-04
Posts: 5

Array (PHP) in article

I need an array in PHP in an article:

I use:

<txp:php>
$gegevens[]="1|Test";
$gegevens[]="2|Test2";
</txp:php>

and it throws “Parse error: parse error, unexpected $end, expecting T_NEW or T_STRING or T_VARIABLE or ‘$’ in…”

How do I properly write the Array-syntax?
This must be correct?

Offline

#2 2007-09-04 11:09:01

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,391
Website GitHub Mastodon

Re: Array (PHP) in article

wimmaskerdrie wrote:

it throws “Parse error: parse error, unexpected $end, expecting T_NEW or T_STRING or T_VARIABLE or ‘$’ in…”

This is because Textile tries to beautify your quotes, which is nothing PHP has learned to value.

Prefix you piece of code with notextile. if it doesn’t contain empty lines, or embrace it with <notextile>...</notextile> tags if you wanted to shield a longish PHP snippet from Textile.

Offline

#3 2007-09-04 11:57:38

wimmaskerdrie
New Member
Registered: 2007-09-04
Posts: 5

Re: Array (PHP) in article

Thanks a lot.
1 more question. Why can’t i use empty lines like this:

<txp:php><notextile>
global $film;
global $gegevens;

//Comment

$gegevens[]=“1|Test”;

</notextile></txp:php>

Offline

#4 2007-09-04 15:23:31

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Array (PHP) in article

Yes you can have & use empty lines with notextile.., like:

notextile.. <txp:php>
$gegevens[]="1|Test";
$gegevens[]="2|Test2";

// Let's echo it out

echo $gegevens;

</txp:php>

p. Your default entry starts here

Cheers!

Last edited by Gocom (2007-09-04 15:25:21)

Offline

#5 2007-09-05 06:55:24

wimmaskerdrie
New Member
Registered: 2007-09-04
Posts: 5

Re: Array (PHP) in article

No.

If I do this:

<notextile><txp:php>
global $film;
global $gegevens;

//Nieuwe regel op deze manier onderdaan zetten JanW
$gegevens[]=“1|Test”;

</txp:php></notextile>

It throws the error unexpected “<”

When I do this:

<notextile><txp:php>
global $film;
global $gegevens;
//Nieuwe regel op deze manier onderdaan zetten JanW
$gegevens[]=“1|Test”;
</txp:php></notextile>

it works.

Offline

#6 2007-09-06 06:57:47

wimmaskerdrie
New Member
Registered: 2007-09-04
Posts: 5

Re: Array (PHP) in article

Anyone?

Offline

#7 2007-09-06 07:04:33

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,349
Website GitHub Mastodon Twitter

Re: Array (PHP) in article

did you try to use “leave text untouched” for that article? You will need to add all the html for it yourself but it should work


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#8 2007-09-06 09:18:06

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Array (PHP) in article

This does work (as Gocom already suggested):

notextile.. <txp:php>
global $film;
global $gegevens;

//Nieuwe regel op deze manier onderdaan zetten JanW
$gegevens[]="1|Test";

</txp:php>

 p. rest of your article (remove the space before the p. at the beginning)

Offline

#9 2007-09-06 09:25:43

wimmaskerdrie
New Member
Registered: 2007-09-04
Posts: 5

Re: Array (PHP) in article

Ok, it works now.
Only if you use the space between notextile.. and <txp:php>

Offline

Board footer

Powered by FluxBB