Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1086651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:50:23+00:00 2026-05-16T22:50:23+00:00

Class_view.php contains the class definition as an associative array: class View { private $viewArray

  • 0

Class_view.php contains the class definition as an associative array:

class View
{
    private $viewArray = array();   

    function getViewArray() {
        return $this->viewArray;
    }

    function addToViewArray($key, $value) {
        $this->view[$key] = $value;
    }
}

In Index.php I have:

$view = new View();
$view->addToViewArray("title", "Projet JDelage");
// Much more code
include ("UI_Header.php");

And the code that causes the error is in UI_Header.php, around the “title” HTML tag:

<?php
    echo '<?xml version="1.0" encoding="utf-8"?>'
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
        <title><?php echo htmlspecialchars($view->getViewArray()['title']);?>
        </title>
        <link rel="stylesheet" media="screen" type="text/css"     title="StyleSheetProjet" href="StyleSheetProjet.css" />
    </head>

I’m trying to get the value associated with the key 'title' to show here.

The error I get is:

Parse error: parse error in Header.php on line 7

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:50:24+00:00Added an answer on May 16, 2026 at 10:50 pm

    The problem is $view->getViewArray()['title']. PHP doesn’t support this yet (it will be included in the next PHP version.) For now you need to create a temporary variable:

    <?php $data = $view->getViewArray(); echo htmlspecialchars($data['title']); ?>
    

    (But maybe you shouldn’t put that in one line, it’s hard to read. Maybe put a $viewData = $view->getViewArray() at the top of that script 😉

    Another way (which is way more elegant) is to implement the ArrayAccess interface in the class, so you could directly use $view['title']. Or, alternatively, if you prefer using object access over array access you could implement the magic __get method (and __set, __unset and __isset methods, if you need them.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View class (OrderView.aspx) which shows the details of an order (Account
I am hoping to dynamically update a ModelForm's inline Meta class from my view.
I have a java class: it.eng.ancona.view.RuoliView$TabElaborazioneFattureValidazione$ElencoDettaglioElaborazioneFattureValidazione$RigaElencoDettaglioElaborazioneFattureValidazione It's so long for multiple inner class. If
Using Eclipse I want to view the source code for a core Java class
class Foo { static bool Bar(Stream^ stream); }; class FooWrapper { bool Bar(LPCWSTR szUnicodeString)
class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple
class A : IFoo { } ... A[] arrayOfA = new A[10]; if(arrayOfA is
class someclass {}; class base { int a; int *pint; someclass objsomeclass; someclass* psomeclass;
class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to
class AbstractQuery { virtual bool isCanBeExecuted()=0; public: AbstractQuery() {} virtual bool Execute()=0; }; class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.