Preheat oven to 350°F (175°C) and grease baking dish.
Mix shredded phyllo dough with melted butter.
Spread half of the dough in the baking dish.
Crumble cheese evenly over the dough.
Layer remaining dough on top.
Bake for 30-40 minutes until golden brown.
Prepare syrup: Boil sugar, water, and lemon juice.
Simmer syrup until slightly thickened, then add flavoring.
Pour syrup over baked Knafeh.
Let cool for 10-15 minutes, then garnish with pistachios if desired.
Serve warm and enjoy your delicious Knafeh.