It happened at the Edward Heston School in the 1600 block of North 54th Street around 1 p.m. Friday.
The school was placed on lockdown, but it was lifted shortly after 2 p.m.
The two boys were taken to Children's Hospital of Philadelphia for observation.
There was no word as to what the substance was or how it got into the school.