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

  • SEARCH
  • Home
  • 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 8821371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:50:14+00:00 2026-06-14T05:50:14+00:00

I’m trying to get the focal length from an image’s EXIF data via PHP.

  • 0

I’m trying to get the focal length from an image’s EXIF data via PHP.

This is the code I’ve got so far:

$exif = exif_read_data("$photo");
$length10 = $exif['FocalLength'];
$length = eval($length10);

$length10 in this case returns something like “1050/10” for 105mm. I don’t know why. All I want to do is have PHP do the math to return 105. When I run this, though, I get the following error message:

[04-Nov-2012 20:06:39] PHP Parse error:  syntax error, unexpected $end in index.php(52) : eval()'d code on line 1

Why?

  • 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-06-14T05:50:15+00:00Added an answer on June 14, 2026 at 5:50 am

    Because 1050/10 is not valid PHP. It has no terminating ; to end the statement, and results in a syntax error.

    php > eval("1050/10");
    PHP Parse error:  syntax error, unexpected end of file in php shell code(1) : eval()'d code on line 1
    

    Rather than eval() it (which technically is dangerous since you’re effectively processing user input even if it comes from EXIF), it is recommended to split on the / or capture the operands with a regular expression and then perform the operation yourself.

    // Test if the value matches the division pattern
    if (preg_match('~^(\d+)/(\d+)$~', $length10, $operands)) {
      // Following a successful match, $operands is an array 
      // containing the full matched string and the two numbers captured
      // in indices [1],[2]
    
      // Watch for div by zero!
      if ($matches[2] !== 0) {
        echo $operands[1] / $operands[2];
      }
    }
    else {
      echo $length10;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post

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.