Add PHP code to a node
Enable PHP Filter module comes with Drupal core


  The PHP filter core module adds the ability to include PHP code in
  posts. PHP is a general-purpose scripting language widely-used for web
  development; the content management system used by this website has
  been developed using PHP.


The following is a guide to add a new text format filter in Drupal 7:

Navigate to the Text formats page Administer » Configuration » Content authoring » Text formats (/admin/config/content/formats).
Click Add Text Format (admin/config/content/formats/add).
Enter the following information:
Name: The name of the filter as it will appear in the administration interface.
Roles: Select one or more roles that will be able to use the format. 
Enabled filters: Enable one or more filters.  Note: As filters are selected, items are added to the Filter Processing Order and Filter Settings sections.
In the Filter processing order section, drag the four-headed arrow to rearrange the order in which the filters will be applied. 
In the Filter settings section, specify the settings for the selected filters. Some filters do not have settings.

Click Save Changes
WARNING: Some HTML markup should only be available to authenticated and trusted users. The PHP option should not be enabled unless it is necessary and care should be taken to limit access to a role representing trusted and knowledgeable users.