Hi everyone,
I am currently working on a project where I am using PHP and Twig together. I am facing an issue while trying to pass a PHP variable into a Twig template. I have tried looking at the documentation, but it is throwing some errors that I can't seem to resolve.
Here is an example of what I have tried:
In my PHP file:
```php
$variable = "Hello World";
// render the template
echo $twig->render('my_template.twig', array('var' => $variable));
```
In my Twig template (my_template.twig):
```twig
<p>{{ var }}</p>
```
I expect the output on the page to be "Hello World", but instead, it is showing "{{ var }}" as plain text.
I have checked the documentation and followed the steps mentioned there, but I am still unable to pass the variable successfully. I am not sure what I am missing or where the error lies.
Has anyone encountered a similar issue before or could someone please guide me on how to pass a PHP variable into Twig correctly? Any help would be appreciated.
Thank you in advance!

User 2: Hey there,
I've encountered a similar issue in the past when passing PHP variables into Twig templates. From your code snippet, it seems like you have everything set up correctly. However, there is one aspect you could consider checking: the syntax you're using to render the template.
Instead of using `echo $twig->render('my_template.twig', array('var' => $variable));`, you can try using the `render()` method of the `Template` class directly. Here's an alternative way to pass the variable into the template:
By loading the template with `$twig->load()`, you'll get a `Template` object that has the `render()` method available. Instead of providing the template file name directly to `render()`, you pass the variable directly to the `render()` method.
Give this alternative method a try and see if it resolves the issue for you. Sometimes, different versions or configurations of Twig can have small differences in syntax requirements.
Let me know if this helps or if you have any more questions. Good luck!