question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PHP not highlighting syntax

See original GitHub issue

I am trying to get php code to highlight on my webpage, but the code is not being syntactically highlighted. Below is my entire react app:

import React from 'react'
import ReactDOM from 'react-dom'
import Syntax from 'react-syntax-highlighter/prism'

const phpCode = `
$data = array(
  'name' => 'James Brown',
  'email' => 'jbrown45@example.com',
  'phone' => '224-555-6798'
);
$data_string = json_encode($data);

$req = curl_init('/users');
curl_setopt($req, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data_string))
);

$res = curl_exec($req);
print($res);
`

ReactDOM.render(<Syntax language="php">{phpCode}</Syntax>, document.getElementById('root'))

That does not highlight the php code.

I’m using:

  • React 16.2.0
  • react-syntax-highlighter 7.0.2

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9

github_iconTop GitHub Comments

2reactions
tylerwraycommented, May 5, 2018

Sorry I’ve been busy with finals. Thanks for this fix!

0reactions
conorhastingscommented, May 3, 2018

fixed in v7.0.4 @wraytw , thanks @wooorm !

Read more comments on GitHub >

github_iconTop Results From Across the Web

highlight_string - Manual - PHP
Outputs or returns html markup for a syntax highlighted version of the given PHP code using the colors defined in the built-in syntax...
Read more >
Syntax highlighting doesn't work after adding a file ... - YouTrack
The file is created, but PhpStorm doesn't seem to register it as a PHP file and there is no syntax highlighting - it...
Read more >
PhpStorm not highlighting PHP code inside a .php file when ...
I am having a problem in PHPStorm where it won't highlight PHP code (but will intellisense it) inside a .php file when it's...
Read more >
PHP syntax highlighting not working properly #162 - GitHub
The syntax highlighting for PHP only works when there's an opening tag.
Read more >
Sublime Text 3 Bug | Solution & Avoidance Of Not Highlighting ...
Sublime Text 3 Bug | Solution & Avoidance Of Not Highlighting PHP Syntax.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found